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.

Writing Your Own Spring Boot Starter

1,144 views

Published on

SpringOne Platform 2016
Speaker: Dieter Hubau; Senior Principal Consultant, Ordina.

Anyone who is actively using Spring must have heard of Spring Boot by now. It is the current de facto standard tool to start with a new Spring project and will become even more prevalent over the coming years. Next to an easy to use interface at start.spring.io and very good documentation, there are a ton of so called Spring Boot Starters which a developer can use to jumpstart their development. While the auto-configuration and starters often seem to be magically endowed creatures originating from the deepest regions of the forest moon of Endor... there are not. In fact, anyone can write his or her own Spring Boot Starter. During the presentation, I will explain the inner workings of a Spring Boot Starter project and go over the necessary code for creating our own. I will use my recently developed starter for integrating Spring Social with a Redis backed datastore. At the end of the session, the audience will know that the Spring Boot autoconfiguration and starter projects are not magical unicorns, but easy to understand components in the Spring Boot ecosystem. They will also learn how to create their own Spring Boot Starter project and hopefully, they will be inclined to become proactively involved in the Spring Boot project.

Published in: Technology

Writing Your Own Spring Boot Starter

  1. 1. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Writing Your Own Spring Boot Starter By Dieter Hubau @dhubau
  2. 2. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ A little bit about me • Dieter Hubau - @dhubau • Java Consultant at Ordina Belgium • Cloud and PaaS Competence Lead • Spring Lover • Games, Blogs, Coding • Soccer! 2
  3. 3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot “Opinionated view of building production-ready Spring applications” 3 • Up and running as quickly as possible • “Convention over configuration” • Production-ready features such as metrics, health checks and externalized configuration • No more XML • Starter POMs simplify configuration in Maven START.SPRING.IO
  4. 4. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot Starter 4 Quick Example
  5. 5. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot Starter - How? “Is it magic?” 5 Yes. Yes it is. That was a lie Everything will be explained
  6. 6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot Starter - Example “Let’s make a minimal Spring Boot application, see what happens” 6
  7. 7. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Business Case “Let’s get to work!” 7 • The FREP Handheld Business Case has concluded that the overall net cost/benefit of a Handheld is unacceptable and is significantly different from the current Non-Handheld. • Initially, we were optimistic that a handheld deployment phase would be valuable for FREP but due to the characteristics of FREP and the recommendations from the Vivid Solutions study, this business case has identified an NPV difference of $500K. • Most of the significant benefits are delivered with FREP online application in Release 1. This application provides significant data quality improvements with business data rules in the system and there is only incremental value to push this out to handhelds. I LIED AGAIN
  8. 8. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ (not so much) Business Case “Rock Paper Scissors Lizard Spock” 8 • Scissors cuts Paper • Paper covers Rock • Rock crushes Lizard • Lizard poisons Spock • Spock smashes Scissors • Scissors decapitates Lizard • Lizard eats Paper • Paper disproves Spock • Spock vaporizes Rock • (and as it always has) Rock crushes Scissors
  9. 9. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ (not so much) Business Case “Rock Paper Scissors Lizard Spock” 9 • Lightweight • Stateless • Cloud Native • Authentication over Twitter • No JDBC
  10. 10. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ (very much) Backup Plan “Josh Long Pokémon” 10 • Spring Boot Starter • Provide endpoint to retrieve Josh Long’s Pokémon • Make it somewhat configurable
  11. 11. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Recap AutoConfiguration is not magic! 11 • @SpringBootApplication enables AutoConfiguration • SpringFactoriesLoader removes the need for classpath scanning • @ConditionalOnClass/Bean allows for flexibility and overriding • Do not start your artifact name with spring-boot-starter! • Autoconfigurations are executed after the regular beans • Control the priority of your starters with @AutoconfigureBefore/After • Check out the autoconfig in debug mode with —debug parameter • Or include the actuator and browse to /autoconfig and /beans
  12. 12. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Any Questions? Now go and try to create your own Spring Boot Starter Check out the demo code at https://github.com/Turbots/SpringOne2016 @springcentral spring.io/blog @pivotal pivotal.io/blog @pivotalcf http://engineering.pivotal.io

×