Introduction to Spring Boot!
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Introduction to Spring Boot!

on

  • 1,267 views

 

Statistics

Views

Total Views
1,267
Views on SlideShare
1,238
Embed Views
29

Actions

Likes
2
Downloads
11
Comments
0

1 Embed 29

https://twitter.com 29

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to Spring Boot! Presentation Transcript

  • 1. SpringBoot! JakubKubryński/kubrynski.com jk@devskiller.com @jkubrynski
  • 2. whoami kubrynski.com @jkubrynskijk@devskiller.com
  • 3. History • 1999 J2EE 1.2 • 2001 xDoclet 1.0 • 2004 Spring Framework 1.0 ● Injection ● POJO oriented ● AOP & transactions • 2006 Java EE 5 • 2013 Spring Boot! kubrynski.com @jkubrynskijk@devskiller.com
  • 4. Focus source: spring.io kubrynski.com @jkubrynskijk@devskiller.com
  • 5. Revolution @RestController @EnableAutoConfiguration public class HelloWorld { @RequestMapping("/") public String helloWorld() { return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(HelloWorld.class, args); } } kubrynski.com @jkubrynskijk@devskiller.com
  • 6. Key features • Stand-alone Spring applications • No code generation / no XML config • Automatic configuration • Starter dependencies • Embedded Tomcat or Jetty • Production-ready environment kubrynski.com @jkubrynskijk@devskiller.com
  • 7. Blocks • SpringApplication • @EnableAutoConfiguration • @ConditionalOnClass • @ConditionalOnBean • @ConditionalOnExpression kubrynski.com @jkubrynskijk@devskiller.com @...OnMissing...
  • 8. Sampleauto-configuration @Configuration @ConditionalOnClass({ MBeanExporter.class }) @ConditionalOnMissingBean({ MBeanExporter.class }) @ConditionalOnExpression("${spring.jmx.enabled:true}") public class JmxAutoConfiguration { ... } kubrynski.com @jkubrynskijk@devskiller.com
  • 9. Availableauto-configurations ● Batch ● Spring Data, JPA, Hibernate, Mongo, Redis ● JMS, RabbitMQ (AMQP) ● Reactor ● Security ● WebMVC, Thymeleaf, Websocket ● Tomcat and Jetty kubrynski.com @jkubrynskijk@devskiller.com
  • 10. Starters • spring-boot-starter • spring-boot-starter-web • spring-boot-starter-test • spring-boot-starter-actuator kubrynski.com @jkubrynskijk@devskiller.com
  • 11. Starters <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> kubrynski.com @jkubrynskijk@devskiller.com
  • 12. Properties public class MailProperties { @Value(“serverAddress”) private InetAddress serverAddress; } java – jar app.jar –serverAddress=10.0.0.1 kubrynski.com @jkubrynskijk@devskiller.com
  • 13. Properties @ConfigurationProperties(prefix=”mail”) public class MailProperties { private InetAddress serverAddress; private Resource template; } mail.serverAddress : 84.123.456.32 mail.template : classpath:mail.vm kubrynski.com @jkubrynskijk@devskiller.com
  • 14. Properties @ConfigurationProperties(prefix=”mail”) public class MailProperties { private InetAddress serverAddress; private Resource template; } mail: serverAddress : 84.123.456.32 template : classpath:mail.vm kubrynski.com @jkubrynskijk@devskiller.com
  • 15. Tests @SpringApplicationConfiguration(classes = Application.class) @ContextConfiguration(classes = Application, loader = SpringApplicationContextLoader) @IntegrationTest kubrynski.com @jkubrynskijk@devskiller.com
  • 16. Profiles • default file is application.properties • customize by spring.config.name • spring.profiles.active = production,mysql • configuration per profile: ● application-production.properties ● conference-test.properties kubrynski.com @jkubrynskijk@devskiller.com
  • 17. Logging • Log4J • Logback • Java Util Logging kubrynski.com @jkubrynskijk@devskiller.com
  • 18. Security • spring-boot-starter-security • @SecurityAutoConfiguration • SecurityProperties ● security.requireSsl = true ● security.enableCsrf = true kubrynski.com @jkubrynskijk@devskiller.com
  • 19. UserInterface • Thymeleaf • Template engine for XML/XHTML/HTML5 • Customizable ● spring.thymeleaf.prefix=classpath:/templates/ ● spring.thymeleaf.suffix=.html ● spring.thymeleaf.mode=HTML5 ● spring.thymeleaf.encoding=UTF-8 kubrynski.com @jkubrynskijk@devskiller.com
  • 20. Productionready • Monitoring endpoints ● /health ● /info ● /metrics ● /trace • JMX / SSH • Auditing kubrynski.com @jkubrynskijk@devskiller.com
  • 21. WAR @EnableAutoConfiguration public class WebApp extends SpringBootServletInitializer{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SampleApplication.class); } } kubrynski.com @jkubrynskijk@devskiller.com
  • 22. Monitoring application ● ApplicationPidListener ● SpringApplication.addListeners(...) ● META-INF/spring.factories org.springframework.context.ApplicationListener= org.springframework.boot.actuate.system.ApplicationPidListener kubrynski.com @jkubrynskijk@devskiller.com
  • 23. Rapidprototyping ● Spring Boot CLI ● $ spring run app.groovy ● $ spring test tests.groovy kubrynski.com @jkubrynskijk@devskiller.com
  • 24. Howdoesithelp? ● Dramatically reduces boilerplate code ● Enables polyglot ● Simplifies integration testing ● Simplifies environment maintenance kubrynski.com @jkubrynskijk@devskiller.com
  • 25. It'sSpring kubrynski.com @jkubrynskijk@devskiller.com
  • 26. Livecoding “Talkischeap –showmethecode” kubrynski.com @jkubrynskijk@devskiller.com
  • 27. Youhavequestions I(probably)haveanswers kubrynski.com @jkubrynskijk@devskiller.com
  • 28. END! THANKYOU kubrynski.com @jkubrynskijk@devskiller.com