Precise and Complete Requirements? An Elusive Goal
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 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
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 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
8. 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.
10. 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
11. 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
14. 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.
15. 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
16. 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>
17. 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
18. 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
20. 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
21. 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”.