Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Eberhard Wolff on Spring Boot

Eberhard Wolff on Spring Boot

More Decks by Enterprise Java User Group Austria

Other Decks in Technology


  1. Spring Boot Main @EnableAutoConfiguration @ComponentScan public class Main { public

    static void main(String[] args) { SpringApplication.run(Main.class, args); } }   Enable Spring Boot Configuration e.g. Web environment etc Scan for Spring annotations e.g. @Component @Configuration etc In this package and all sub packages Start application e.g. Tomcat, Spring web environment etc @SpringBootApplication = @ComponentScan+ @EnableAutoConfiguration+ @Configuration
  2. Spring Boot: Maven pom.xml <project ...> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.1.RELEASE</version>

    </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> ... </dependencies> Configuration inherits from parent Sets versions for dependencies Add all needed libs for a web app Many starters available
  3. Spring Boot: Maven pom.xml ... <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId>

    </plugin> </plugins> </build> </project>   Makes WAR / JAR executable Support mvn spring-boot:run to run the app
  4. Spring Boot §  Build much easier §  Supports Gradle &

    Ant, too §  Not limited to simple application §  Can add any other library §  Application much easier to test, debug etc §  Simple code
  5. Spring Data JPA §  Makes implementation of repositories trivial § 

    Just provide an interface §  Needs JPA infrastructure of course
  6. Spring Data JPA Repository public interface CustomerRepository extends JpaRepository<Customer, Long>

    { List<Customer> findByName(String name); }   Defines all basic CRUD (Create, Read, Update, Delete) operations Implementation created by naming convention Add Spring Boot Starter Data JPA No further configuration Without Spring Boot <repositories base-package="de.project" /> or @EnableJpaRepositories("de.project")
  7. Behind the Scenes §  DataSource for HSQL created §  JPA

    infrastructure created §  Thymeleaf infrastructure created §  How does it work? §  Convention over configuration
  8. Spring Boot §  Creates sensible infrastructure defaults §  i.e. DataSource

    if HSQL is on the classpath §  Done by *AutoConfiguration classes
  9. Spring Boot Starter amqp aop batch data-jpa data-mongodb data-rest integration

    jdbc mobile redis security test web websocket actuator remote-shell jetty tomcat log4j logback data-solr data-elasticsearch data-gemfire groovy-templates freemarker thymeleaf mustache undertow velocity social-facebook social-linkedin social-twitter
  10. Dev §  Turn Around §  Thymeleaf Templates can be changed

    on the fly §  …same with class files §  Spring Loaded makes reloading more powerful
  11. CRaSH Shell §  Ever ssh’d into your application? §  Enter

    CRaSH §  External library integrated into Spring Boot §  Alternative approach to operations
  12. Actuator §  Provide information about the application §  Via http

    / JSON §  Can be evaluated by monitoring tools etc. §  Another alternative approach to monitoring
  13. Deploy §  Just package everything in an executable JAR § 

    …or a WAR §  Based on Maven or Gradle §  Build in configuration (YAML, properties etc.)
  14. What‘s next? Spring Cloud §  Technologies for Micro Services § 

    E.g. Configuration §  Resilience §  Netflix stack §  Cloud Bus §  Cloud Security §  Based on Spring Boot
  15. Conclusion §  Easy to start §  Can add libraries and

    features as needed §  Dev: Quick turn around §  Ops: Integrated monitoring §  Ops: Easy deployment §  Didn’t show Groovy support
  16. Spring Boot & Microservices §  Simplifies deployment §  Standardizes Ops

    interface §  Simplify creating REST / web applications