Complete the code to specify the active Spring profile in application.properties.
spring.profiles.active=[1]The spring.profiles.active property sets the active profile. Here, test activates the test profile.
Complete the annotation to activate the 'test' profile for a Spring Boot test class.
@ActiveProfiles([1]) public class MyServiceTest {}
The @ActiveProfiles annotation activates the specified profile for the test class. Using "test" activates the test profile.
Fix the error in the YAML configuration to define a 'test' profile property.
spring:
profiles: [1]
datasource:
url: jdbc:h2:mem:testdbIn YAML, to define properties for a profile, use test after profiles:. So spring.profiles: test defines the 'test' profile section.
Fill both blanks to correctly inject a property value from the 'test' profile in a Spring component.
@Value("$[1]") private String [2];
The @Value annotation injects the property named app.test.value. The variable name testValue is a good descriptive name for this property.
Fill all three blanks to create a test configuration class that activates the 'test' profile and defines a bean.
@Configuration @Profile([1]) public class TestConfig { @Bean public String sampleBean() { return [2]; } public String getProfile() { return [3]; } }
The @Profile annotation activates the 'test' profile. The bean returns a test string. The method returns the profile name 'test'.