0
0
Spring Bootframework~10 mins

Environment-based profiles in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to activate the 'dev' profile in Spring Boot.

Spring Boot
spring.profiles.active=[1]
Drag options to blanks, or click blank then click option'
A"dev"
B"prod"
C"test"
D"default"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes incorrectly or missing them.
Setting the profile to a name that does not exist.
2fill in blank
medium

Complete the annotation to specify a bean only for the 'prod' profile.

Spring Boot
@Profile([1])
public class ProductionService {}
Drag options to blanks, or click blank then click option'
A"default"
B"test"
C"prod"
D"dev"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the profile name.
Using the wrong profile name.
3fill in blank
hard

Complete the YAML to activate the 'test' profile.

Spring Boot
spring:
  profiles: [1]
  datasource:
    url: jdbc:h2:mem:testdb
Drag options to blanks, or click blank then click option'
Ainclude: test
Benabled: test
Cdefault: test
Dactive: test
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'include' or 'enabled' instead of 'active'.
Wrong indentation in YAML.
4fill in blank
hard

Fill the blank to define a bean that is active only for 'dev' and 'test' profiles.

Spring Boot
@Profile([1])
public class DevTestService {
  // bean code
}
Drag options to blanks, or click blank then click option'
A"dev & test"
B"dev", "test"
C"dev | test"
D"prod"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '&' or '|' syntax.
Listing profiles without quotes or commas.
5fill in blank
hard

Fill the blanks to create a properties file name for the 'prod' profile with YAML format.

Spring Boot
application-[1].[2]
Drag options to blanks, or click blank then click option'
Aprod
Bproperties
Cyml
Dyaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.properties' extension for YAML files.
Misspelling the profile name.