Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Javentura - Spring Boot under the hood

1,239 views

Published on

Some explanations about the inner workings of Spring Boot

Published in: Software
  • Be the first to comment

Javentura - Spring Boot under the hood

  1. 1. SPRING BOOT UNDER THE HOOD @NICOLAS_FRANKEL
  2. 2. ME, MYSELF AND I @nicolas_frankel #springboot 2  Developer/Software - /Solution Architect • Java • As consultant
  3. 3. HYBRIS, AN SAP COMPANY 3 @nicolas_frankel #springboot
  4. 4. @nicolas_frankel #springboot 4
  5. 5. @nicolas_frankel #springboot 5
  6. 6. SPRING BOOT ACTUATOR <dependency> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-actuator </artifactId> </dependency> @nicolas_frankel #springboot 6
  7. 7. /HEALTH { "status" : "UP", "diskSpace" : { "status" : "UP", "total" : 499055067136, "free" : 254812135424, "threshold" : 10485760 }, "db" : { "status" : "UP", "database" : "HSQL Database Engine", "hello" : 1 } } @nicolas_frankel #springboot 7
  8. 8. SPRING BOOT Works well until: • It doesn’t anymore • Or you want to change the default behavior @nicolas_frankel #springboot 8
  9. 9. CONFIGURATION – POM.XML <dependency> <groupId> org.springframework.boot </groupId> <artifactId> spring-boot-starter-data-jpa </artifactId> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <scope>runtime</scope> </dependency> @nicolas_frankel #springboot 9
  10. 10. LET’S CHECK HOW IT WORKS @nicolas_frankel #springboot 10
  11. 11. STARTERS DEPENDENCIES @nicolas_frankel #springboot 11
  12. 12. SPRING-BOOT-AUTOCONFIGURE.JAR @nicolas_frankel #springboot 12
  13. 13. SPRING.FACTORIES @nicolas_frankel #springboot 13
  14. 14. @JPAREPOSITORIESAUTOCONFIGURATION @Configuration @ConditionalOnBean(DataSource.class) @ConditionalOnClass(JpaRepository.class) @ConditionalOnMissingBean({ JpaRepositoryFactoryBean.class, JpaRepositoryConfigExtension.class }) @ConditionalOnProperty( prefix = "spring.data.jpa.repositories", name = "enabled", havingValue = "true", matchIfMissing = true) @Import(JpaRepositoriesAutoConfigureRegistrar.class) @AutoConfigureAfter( HibernateJpaAutoConfiguration.class) public class JpaRepositoriesAutoConfiguration { } @nicolas_frankel #springboot 14
  15. 15. @CONDITIONAL @ConditionalOnBean @ConditionalOnClass @ConditionalOnMissingBean @ConditionalOnProperty etc. @nicolas_frankel #springboot 15
  16. 16. REMEMBER @PROFILE? @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface Profile { String[] value(); } @nicolas_frankel #springboot 16
  17. 17. THIS IS THE NEW @PROFILE @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) @Documented @Conditional(ProfileCondition.class) public @interface Profile { String[] value(); } @nicolas_frankel #springboot 17
  18. 18. @CONDITIONAL & CONDITION @nicolas_frankel #springboot 18
  19. 19. @CONDITIONAL & CONDITION Enables calling of a @Bean- annotated method • In the context of a @Configuration class @nicolas_frankel #springboot 19
  20. 20. ENOUGH TALK… @nicolas_frankel #springboot 20
  21. 21. OUT-OF-THE-BOX CONDITIONS Condition Description OnBeanCondition Checks if a bean is in the Spring factory OnClassCondition Checks if a class is on the classpath OnExpressionCondition Evalutates a SPeL expression OnJavaCondition Checks the version of Java OnJndiCondition Checks if a JNDI branch exists OnPropertyCondition Checks if a property exists OnResourceCondition Checks if a resource exists OnWebApplicationCondition Checks if a WebApplicationContext exists @nicolas_frankel #springboot 21
  22. 22. COMPOSITE CONDITIONS Condition Description AllNestedConditions AND condition AnyNestedConditions OR condition NoneNestedCondition NOT condition @nicolas_frankel #springboot 22
  23. 23. OUR OWN STARTER @nicolas_frankel #springboot 23
  24. 24. Q&A @nicolas_frankel #springboot 24 http://blog.frankel.ch/ @nicolas_frankel http://frankel.in/ https://git.io/v2f3O

×