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.

Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)


Published on

Slide deck for the talk "Building a Spring Boot Application - Ask the Audience!" at JVMCon 2018.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)

  1. 1. Building aBuilding a Spring BootSpring Boot ApplicationApplication (ask the audience)(ask the audience) Hanno Embregts @hannotify
  2. 2. Hanno?Hanno?Hanno?Hanno?Hanno?
  3. 3. IntroducingIntroducingIntroducingIntroducingIntroducing Spring BootSpring BootSpring BootSpring BootSpring Boot
  4. 4. Spring Boot?Spring Boot? ( ) "Takes an opinionated view of building production-ready Spring applications. Favors convention over con guration and is designed to get you up and running as quickly as possible."
  5. 5. Key features?Key features? create stand-alone Spring applications embed web server directly (no WAR les) automatic Spring con guration wherever possible no code generation and no XML con guration still offering all Spring features.
  6. 6. Pros?Pros? no separate web server needed better debugging in IDEs faster deployments (about 50%) no web.xml or con guration classes needed up and running with one Java le and a build script. ( )
  7. 7. Cons?Cons? custom con guration will be a bit of a puzzle porting your legacy Spring project would be a disaster! it uses Spring, excluding roughly half of the Java community.
  8. 8. Starting OutStarting OutStarting OutStarting OutStarting Out
  9. 9. About What We ClaimedAbout What We Claimed Earlier...Earlier... "up and running with one Java le and a build script"
  10. 10. Java le(s)Java le(s) // imports... @RestController public class HelloController { @RequestMapping("/") public String index() { return "Greetings from Spring Boot!"; } } // imports... @SpringBootApplication public class Application { public static void main(String[] args) {, args); } }
  11. 11. Build scriptBuild script apply plugin: 'java' apply plugin: 'idea' apply plugin: 'org.springframework.boot' jar { // some properties... } // repositories... dependencies { compile("org.springframework.boot:spring-boot-starter-web") testCompile("junit:junit") }
  12. 12. Starter DependenciesStarter Dependencies a set of convenient dependency descriptors follow the naming pattern spring-boot-starter- * Name Purpose spring-boot-starter Core starter, includes auto-con g & logging spring-boot-starter-test Test starter, includes JUnit, Hamcrest & Mockito spring-boot-starter-web Starter for Spring MVC Web applications spring-boot-starter-data-jpa Spring Data with JPA (more starters at ) boot/docs/current/reference/htmlsingle/#using-boot-starter
  13. 13. Spring InitializrSpring Initializr (a quick way to download a project setup)
  14. 14. Live codingLive codingLive codingLive codingLive coding
  15. 15. Kahoot! #1
  16. 16. Kahoot! #2
  17. 17. Implementing RepositoryImplementing Repository MethodsMethods De ne them in a @Query annotation Use one of the many supported query methods ( ) methods.query-creation List<Entity> findByNameContainingIgnoreCase(String name);
  18. 18. Wrap-up &Wrap-up &Wrap-up &Wrap-up &Wrap-up & QuestionsQuestionsQuestionsQuestionsQuestions
  19. 19. Wrap-upWrap-up Spring Boot gets you up & running quickly; assumes standard con guration for rapid development; plays nice with a wide range of frameworks; is up to the task no matter what choices you make.
  20. 20. And what if I prefer JavaEE?And what if I prefer JavaEE? At least you can use embedded servers: TomEE Embedded ( ) Wild y Swarm ( ) Quick assembly with JBoss ShrinkWrap ( ) http://wild not.html
  21. 21. Any questions?Any questions?Any questions?Any questions?Any questions?
  22. 22. Thank you! ☺Thank you! ☺ Just can't get enough? @hannotify