- Spring Boot makes it effortless to create Spring-powered, production-ready services without a lot of code!
- Out-of-the-box nonfunctional features like security, metrics, health-checks, embedded servers, and externalized configuration made Boot an easy choice for us.
- Bootstarting Spring
- There are four core tricks that Spring Boot performs:
- Automatic configuration—Spring Boot can automatically provide configuration for application functionality common to many Spring applications.
- Starter dependencies—You tell Spring Boot what kind of functionality you need, and it will ensure that the libraries needed are added to the build.
- The command-line interface—This optional feature of Spring Boot lets you write complete applications with just application code, but no need for a traditional project build.
- The Actuator—Gives you insight into what’s going on inside of a running Spring Boot application.
- There are four core tricks that Spring Boot performs:
- Initializing a Spring Boot project with Spring Initializr
- Developing your first Spring Boot application
- The @SpringBootApplication enables Spring component-scanning and Spring Boot auto-configuration.
- @Configuration
- @ComponentScan
- @EnableAutoConfiguration
- Spring Boot addresses project dependency complexity by providing several dozen “starter” dependencies.
- Via transitive dependencies, adding these four dependencies is the equivalent of adding several dozen individual libraries to the build.
- Appendix B lists all of the starters
- Auto-configuration frees you from the boilerplate configuration that is common among Spring applications without Spring Boot.
- The @SpringBootApplication enables Spring component-scanning and Spring Boot auto-configuration.
- Customizing configuration
- E.g., although Spring Boot provides some basic auto-configuration for security, you’ll certainly want to override it to meet your specific security requirements.
- all you need to do to override Spring Boot auto-configuration is to write
explicit configuration. - As for the application.properties and application.yml files, they can reside in any of four locations:
- Externally, in a /config subdirectory of the directory from which the application is run
- Externally, in the directory from which the application is run
- Internally, in a package named “config”
- Internally, at the root of the classpath
- Appendix C gives an exhaustive list of these properties
- Fine-tuning auto-configuration
- DISABLING TEMPLATE CACHING
- CONFIGURING THE EMBEDDED SERVER
- CONFIGURING LOGGING
- CONFIGURING A DATA SOURCE
- Profiles are a type of conditional configuration where different beans or configuration classes are used or ignored based on what profiles are active at runtime.
- Testing with Spring Boot
- [Sorry! Skipped for now.]
- Getting Groovy with the Spring Boot CLI
- [Sorry! Skipped for now.]
- Applying Grails in Spring Boot
- [Sorry! Skipped for now.]
- Taking a peek inside with the Actuator
- The Actuator offers production-ready features such as monitoring and metrics to Spring Boot applications.
- The Actuator’s features are provided by way of several REST endpoints, a remote shell, and Java Management Extensions (JMX).
- spring-boot-starter-actuator
- The endpoints can be organized into three distinct categories: configuration endpoints, metrics endpoints, and miscellaneous endpoints.
- Connecting to the Actuator remote shell
- spring-boot-starter-remote-shell
- Securing Actuator endpoints
- antMatchers
- access
- management.context-path=/mgmt
- Deploying Spring Boot applications
- ways to build and run Spring Boot applications
- Running the application in the IDE (either Spring ToolSuite or IntelliJ IDEA)
- Running from the command line using the Maven spring-boot:run goal or Gradle bootRun task
- Using Maven or Gradle to produce an executable JAR file that can be run at the command line
- Using the Spring Boot CLI to run Groovy scripts at the command line
- Using the Spring Boot CLI to produce an executable JAR file that can be run at the command line
- Executable JAR files and the Spring Boot CLI are great choices when deploying to a cloud environment.
- Spring Boot deployment choices
- Raw Groovy source
- Executable JAR
- WAR
- Spring Boot includes auto-configuration support for two popular database migration libraries:
- Flyway (http://flywaydb.org)
- Liquibase (http://www.liquibase.org/)
- Pushing to the cloud
- Cloud Foundry
- Heroku
- spring-boot-starter-cloud-connectors
- ways to build and run Spring Boot applications