This document contains notes on Spring Boot concepts including:
1. An overview of Spring Boot starters, auto-configuration, customization rules, and the actuator module for monitoring.
2. Details on customizing auto-configuration through property overrides, excluding specific auto-configuration classes, and dependency injection with annotations.
3. An explanation of loading order for Spring beans and when to use the @Order annotation, such as for overriding security configurations in Spring Boot applications.
2. backend developer for
interested in full stack development as well
https://medium.com/@kobi97
kobi97@gmail.com
2
3. Spring Boot Hello World
Spring Boot Management (Actuator)
Spring Boot Starter Web (jar vs war)
Auto-Configuration Mechanism
Customizing Rules
Order of Loading Spring Beans
When do I use @Order?
Conclusion
For developers who use Spring Framework
3
7. How do I customizing Spring Boot?
It’s very important to understand
Auto-Configuration Mechanism
I would like to introduce
My Customizing Rules to you
7
8. Wait a second!
We need to know first
Spring Boot Actuator
For monitoring & auto-configuration
8
12. Customizing Rule 1
- Overriding of values, properties
PropertySource order
1. Command line arguments
2. JNDI attributes from java:comp/env
3. Java System properties (System.getProperties())
4. OS environment variables
5. A RandomValuePropertySource that only has properties in random.*.
6. application-{profile}.properties(yml) – outside jar
7. - inside jar
8. application.properties(yml) - outside jar
9. - inside jar
10. @PropertySource annotations on your @Configuration classes
11. Default properties (specified using SpringApplication.setDefaultProperties)
http://docs.spring.io/spring-boot/docs/1.2.3.RELEASE/reference/htmlsingle/#boot-features-external-config 12
31. @componentScan
1
2
3
1
23
4
5
6 Question
1. Case of using @Lazy or @Primary on @Bean?
2. Case of adding InternalConfig3.class in @Import in
InternalConfig1?
3. Case of using @Order on @Configuration or @Bean?
4. Case of Making @Component InternalConfig4 at the same
package of InternalConfig3?
31
loading order of Spring Beans - Test (2)
33. Understand
1. Execution order is in Auto-Configuration
2. After loading of beans by @SpringBootApplication ,
check Auto-Configuration’s conditions and load remained beans
2
1
1
33
34. @Order(2147483547) SpringBootAuthenticationConfigurerAdapter
@Order(2147483636) ManagementServerProperties.ACCESS_OVERRIDE_ORDER
@Order(2147483637) ManagementSecurityAutoConfiguration
@Order(2147483640) SecurityProperties.ACCESS_OVERRIDE_ORDER
@Order(2147483642) ApplicationWebSecurityConfigurerAdapter
http://docs.spring.io/spring-security/site/docs/3.2.x/reference/htmlsingle/#multiple-httpsecurity
Order
In spring boot’s spring security
• Application override
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
• Actuator(ManagementServer) override
@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)
34
35. When do I use @Order?
filter, auto-configuration,
WebSecurityConfigurerAdapter …
35
36. Auto-Configuration
Mechanism
Loading order of
Spring Beans
How to use
customizing
spring-boot?
Customizing Rules #1,2,3 …
Spring Boot Guides
Spring Boot Sources
googling
For Ops, Actuator/Remote Shell spring-boot-
starter-web
(jar vs war)
36
37. http://docs.spring.io/spring-boot/docs/1.2.3.RELEASE/reference/htmlsingle/ (us-guide)
https://github.com/spring-projects/spring-boot/
http://u4u.pe.kr/redmine/projects/nicedream/wiki/Spring_Boot (kr-guide)
http://tadtech.blogspot.kr/2013/10/how-spring-boot-enables-actuator-by.html
http://docs.spring.io/spring-
security/site/docs/4.0.1.RELEASE/reference/htmlsingle/#multiple-httpsecurity
Learning Spring Boot - Greg L. Turnquist
Spring in Action 4th
37