Tim Hobson Principal Engineer, Chief Caffeine Officer @ Java on Rails - Using Spring Boot For Rapid Application Development
About Me 2 Software Developer with a bad habit of leveraging frameworks Not a fan of re-inventing wheels every project Still believe you can move fast with good architecture
Agenda 3 Why Spring Boot Code RAD GOAL: Spring Boot has been demystified, looks promising, and you are inspired to give it a test drive.
Rapid Application Development
Rapid Application Development Components, Frameworks and Platforms The platform choice you make should enable you to move fast using the best of breed frameworks and components
Components 6 High-level software systems are built using components (or modules) Leveraging existing components – saves time, – reduces opportunity for defects, – lets you focus on your value added work. EG: Database connection pools, JSON and XML Parsers, Security libraries, HTTP Clients etc… As an application developer, you are not being paid to build commodity services
Choices, Choices… 7 97,613 packages49,603 packages 87,864 packages 89,387 packages 27,580 packages
Frameworks 8 Frameworks typically provide a collection of curated Components that work seamlessly together Frameworks provide implied (or explicit) patterns and practices to help maintain good architecture and maintainability Frameworks provide proven combinations of components in use for known use cases.
Choices, Choices… 9
Platforms 10 Platforms go beyond software components and frameworks – Tooling – Deployment – Management – Testing – Maintenance – Versioning Platforms are trying to create cohesive technology experiences for developers and businesses Less for you to worry about, more time to focus on your domain
Making Good Choices 11 What do I need in the short term? What might I need in the future? How has the framework evolved, will it continue? Are there enough people skilled in this framework? Is the documentation and support good? Is it an ordeal or a joy to work with? There are more considerations than how easy “Hello World” is
Why Spring Boot?
?
A Cohesive Platform The Spring Platform consists of components and frameworks that are useful in and of themselves, but are brought together through Boot in a way that lends itself to true RAD. The framework is road-tested, and continues to be actively developed, keeping up with the latest technologies and patterns (Big Data, Reactive, HATEOS, Microservices, Cloud-deployed) and actively partnering with other OSS projects.
Spring Boot What is it? – Dependency Management “Simplification” – Automatic Component Configuration – Cross-cutting infrastructure services – Deployment and Packaging alternatives How does it do it? – “Starter Packs” of dependencies – Convention-based configuration – Production-ready services such as metrics, health, app lifecycle. – Maven and Gradle plugins
Dependency Management 16 Starter Packs bring together Spring and Third-Party dependencies needed to do something functionally: – Web – Data – Security – Test Versioning controlled by a parent pom.xml Include the starter packs you need, and go. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
The Magic of Auto-Configuration 17 Configures based on what is in your classpath Configures based on what @Beans are in place and which aren’t Configures based on your application.yml or application.properties @EnableAutoConfiguration
So What’s So Great About That? EG: Writing a JSON Service that reads from a DB 18 Spring Boot Way • Use/Include Spring Boot Starter Parent in pom/Gradle, add Spring Boot Starter Web and JPA • Write Controller, Service, Repository Beans and Domain Objects • Write Application class with @EnableAutoConfiguration • Run as a Jar. Old Spring Way • Configure Web Container • Create Web Project • Configure POM/Gradle/Ant dependencies (with versions) build and and packaging (150 lines +) • Configure web.xml with Spring context config files, dispatcher servlet, servlet mapping, Spring security Filter, etc.. • Write Controller, Service, Repository Beans and Domain Objects • Configure *.xml files (Or annotated @Configuration Beans) with Bean definitions, View resolvers, content-negotiation, controller mapping, resource handling, error handlers, db pooling, connections, profiles, transactionmanager, jdbc templates or JPA config. • Write code to import initial data from script
Infrastructure Services 19 Audit Metrics Guages Tracing Configuration Views Remote management via SSH All Part of the Actuator Component
Package and Deployment Alternatives 20 Package as a JAR – Choose embedded container (Jetty, Tomcat) – Configure container programmatically and/or via application config – Run using java –jar Package as a WAR – No web.xml required – Spring Dispatcher Servlet is auto-configured – Deploy to any Servlet container
Choices, Choices… Do you already use Spring? • Simplify your configuration • Keep up with the latest version compatibility matrix • Introduce Circuit Breaker patterns, distributed configuration, metrics and management APIs • Get stuff done faster Are you considering using Spring? • Skip the rewrite for the JVM and write durable code! • Leverage Dependency Injection, AOP, abstractions and integrations for major data stores, security standards, web standards and more. • Fail to understand why it was known as “hard to use”.
Code
To-Boot https://github.com/hoserdude/to-boot git clone git@github.com:hoserdude/to-boot.git Sample App to demonstrate all manner of things, cobbled together in about 2 days. See README.md for instructions
Things We Will Explore Boostrapping (POM, Application.class) Controllers (Routes, Marshalling, Resource Handling) Views (Thymeleaf, AngularJS) APIs (Swagger, DTO definition) Security Persistence (Config, Repositories, Domain Beans) Application Structure, DI Monitoring and Metrics Deployment Options 24
Closing Thoughts
Find Out More 26 • http://spring.io/projects • http://spring.io/guides
THANK YOU @hoserdude @hoserdude @hoserdude hoserdude.com

Java on Rails SV Code Camp 2014

  • 1.
    Tim Hobson Principal Engineer,Chief Caffeine Officer @ Java on Rails - Using Spring Boot For Rapid Application Development
  • 2.
    About Me 2 Software Developerwith a bad habit of leveraging frameworks Not a fan of re-inventing wheels every project Still believe you can move fast with good architecture
  • 3.
    Agenda 3 Why Spring Boot Code RAD GOAL:Spring Boot has been demystified, looks promising, and you are inspired to give it a test drive.
  • 4.
  • 5.
    Rapid Application Development Components,Frameworks and Platforms The platform choice you make should enable you to move fast using the best of breed frameworks and components
  • 6.
    Components 6 High-level software systemsare built using components (or modules) Leveraging existing components – saves time, – reduces opportunity for defects, – lets you focus on your value added work. EG: Database connection pools, JSON and XML Parsers, Security libraries, HTTP Clients etc… As an application developer, you are not being paid to build commodity services
  • 7.
    Choices, Choices… 7 97,613 packages49,603packages 87,864 packages 89,387 packages 27,580 packages
  • 8.
    Frameworks 8 Frameworks typically providea collection of curated Components that work seamlessly together Frameworks provide implied (or explicit) patterns and practices to help maintain good architecture and maintainability Frameworks provide proven combinations of components in use for known use cases.
  • 9.
  • 10.
    Platforms 10 Platforms go beyondsoftware components and frameworks – Tooling – Deployment – Management – Testing – Maintenance – Versioning Platforms are trying to create cohesive technology experiences for developers and businesses Less for you to worry about, more time to focus on your domain
  • 11.
    Making Good Choices 11 Whatdo I need in the short term? What might I need in the future? How has the framework evolved, will it continue? Are there enough people skilled in this framework? Is the documentation and support good? Is it an ordeal or a joy to work with? There are more considerations than how easy “Hello World” is
  • 12.
  • 13.
  • 14.
    A Cohesive Platform TheSpring Platform consists of components and frameworks that are useful in and of themselves, but are brought together through Boot in a way that lends itself to true RAD. The framework is road-tested, and continues to be actively developed, keeping up with the latest technologies and patterns (Big Data, Reactive, HATEOS, Microservices, Cloud-deployed) and actively partnering with other OSS projects.
  • 15.
    Spring Boot What isit? – Dependency Management “Simplification” – Automatic Component Configuration – Cross-cutting infrastructure services – Deployment and Packaging alternatives How does it do it? – “Starter Packs” of dependencies – Convention-based configuration – Production-ready services such as metrics, health, app lifecycle. – Maven and Gradle plugins
  • 16.
    Dependency Management 16 Starter Packsbring together Spring and Third-Party dependencies needed to do something functionally: – Web – Data – Security – Test Versioning controlled by a parent pom.xml Include the starter packs you need, and go. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
  • 17.
    The Magic ofAuto-Configuration 17 Configures based on what is in your classpath Configures based on what @Beans are in place and which aren’t Configures based on your application.yml or application.properties @EnableAutoConfiguration
  • 18.
    So What’s SoGreat About That? EG: Writing a JSON Service that reads from a DB 18 Spring Boot Way • Use/Include Spring Boot Starter Parent in pom/Gradle, add Spring Boot Starter Web and JPA • Write Controller, Service, Repository Beans and Domain Objects • Write Application class with @EnableAutoConfiguration • Run as a Jar. Old Spring Way • Configure Web Container • Create Web Project • Configure POM/Gradle/Ant dependencies (with versions) build and and packaging (150 lines +) • Configure web.xml with Spring context config files, dispatcher servlet, servlet mapping, Spring security Filter, etc.. • Write Controller, Service, Repository Beans and Domain Objects • Configure *.xml files (Or annotated @Configuration Beans) with Bean definitions, View resolvers, content-negotiation, controller mapping, resource handling, error handlers, db pooling, connections, profiles, transactionmanager, jdbc templates or JPA config. • Write code to import initial data from script
  • 19.
  • 20.
    Package and DeploymentAlternatives 20 Package as a JAR – Choose embedded container (Jetty, Tomcat) – Configure container programmatically and/or via application config – Run using java –jar Package as a WAR – No web.xml required – Spring Dispatcher Servlet is auto-configured – Deploy to any Servlet container
  • 21.
    Choices, Choices… Do youalready use Spring? • Simplify your configuration • Keep up with the latest version compatibility matrix • Introduce Circuit Breaker patterns, distributed configuration, metrics and management APIs • Get stuff done faster Are you considering using Spring? • Skip the rewrite for the JVM and write durable code! • Leverage Dependency Injection, AOP, abstractions and integrations for major data stores, security standards, web standards and more. • Fail to understand why it was known as “hard to use”.
  • 22.
  • 23.
    To-Boot https://github.com/hoserdude/to-boot git clone git@github.com:hoserdude/to-boot.git SampleApp to demonstrate all manner of things, cobbled together in about 2 days. See README.md for instructions
  • 24.
    Things We WillExplore Boostrapping (POM, Application.class) Controllers (Routes, Marshalling, Resource Handling) Views (Thymeleaf, AngularJS) APIs (Swagger, DTO definition) Security Persistence (Config, Repositories, Domain Beans) Application Structure, DI Monitoring and Metrics Deployment Options 24
  • 25.
  • 26.
    Find Out More 26 •http://spring.io/projects • http://spring.io/guides
  • 27.