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/ Writing Your Own Spring Boot Starter By Dieter Hubau @dhubau

Writing Your Own Spring Boot Starter

Embed Size (px)

Citation preview

Page 1: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Writing Your Own Spring Boot Starter

By Dieter Hubau@dhubau

Page 2: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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

Page 3: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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 MavenSTART.SPRING.IO

Page 4: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot Starter

4

Quick Example

Page 5: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot Starter - How?“Is it magic?”

5

Yes. Yes it is. That was a lie

Everything will be explained

Page 6: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

Spring Boot Starter - Example“Let’s make a minimal Spring Boot application, see what happens”

6

Page 7: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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

Page 8: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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

Page 9: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

(not so much) Business Case“Rock Paper Scissors Lizard Spock”

9

• Lightweight

• Stateless

• Cloud Native

• Authentication over Twitter

• No JDBC

Page 10: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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

Page 11: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /

RecapAutoConfiguration 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

Page 12: Writing Your Own Spring Boot Starter

Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /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

@springcentralspring.io/blog

@pivotalpivotal.io/blog

@pivotalcfhttp://engineering.pivotal.io