Spring Boot Flashcards
What are the 3 annotations that make up @SpringBootApplication?
- @SpringBootConfiguration
- @ComponentScan
- @EnableAutoConfiguration
Which annotation can you use to scan for components defined outside of the main package?
@SpringBootApplication(scanBasePackages=String[])
What are the 2 steps necessary to load profile-specific application.properties?
@Profile(profileName)
application-[profileName].properties
What are the 4 ways to disable auto-configuration?
- Define your own beans
- application.properties
spring.autoconfigure.exclude=[package]
@SpringBootApplication(exclude=Class[])
True or False
Spring related properties should be defined in application.properties and non-spring related properties should be defined elsewhere
True
What does SpringApplication.run()
return?
ConfigurableApplicationContext which is a subtype of ApplicationContext
How can you change the logging level of a Spring Boot application?
logging.level.[package]=?
INFO is the default logging level
Does Spring Boot autoconfigure a datasource if an embedded database is used?
Yes. For example, when HSQLDB is used, Spring boot will autoconfigure a datasource
Is application.properties loaded before other property files?
Yes
What is the command to build a Spring Boot executable with Maven?
./mvnw package
Which file will always load?
- application-local.properties
- application-cloud.properties
- application.properties
application.properties
What is the syntax for adding command line properties to a Spring Boot application?
--key=value
True or False
If you define a set of configuration keys for your own components, we recommend you group them in a POJO annotated with @ConfigurationProperties
True
True or False
spring.profiles.include
overrides existing properties when used
False