Complete the code to specify the active Spring profile in application.properties.
spring.profiles.active=[1]The property spring.profiles.active sets the active profile. Here, dev is a common profile name.
Complete the filename to create a profile-specific properties file for the test profile.
application-[1].propertiesSpring Boot loads application-{profile}.properties files based on the active profile. For the test profile, the file is application-test.properties.
Fix the error in the annotation to activate the prod profile in a Spring Boot test class.
@ActiveProfiles("[1]")
The @ActiveProfiles annotation activates the specified profile for tests. The profile name must exactly match the profile defined in your configuration, here prod.
Fill both blanks to define a bean that is only created when the dev profile is active.
@Bean @Profile([1]) public DataSource dataSource() { return [2]; }
The @Profile annotation requires the profile name as a string, so it must be quoted. The bean method returns a new instance of the data source implementation.
Fill all three blanks to create a YAML profile-specific configuration for staging with a custom server port.
spring:
profiles:
active: [1]
server:
port: [2]
logging:
level:
root: [3]This YAML snippet activates the staging profile, sets the server port to 8085, and sets the root logging level to DEBUG.