A Sneak Peek at Spring Boot 2.0
By Madhura Bhave / Phil Webb
@madhurabhave23 / @phillip_webb
1
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Agenda
• What’s New
• Infrastructure upgrades
• Spring Framework 5
• What’s Changed
• Configuration properties
• Gradle plugin
• Actuator endpoints
• What’s Evolving
• Security
• Metrics
2
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s New
• Infrastructure upgrades
• Spring Framework 5
3
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s New
• Infrastructure upgrades
• Spring Framework 5
4
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Infrastructure Upgrades
5
8+ 8+
5.23
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s New
• Infrastructure Upgrades
• Spring Framework 5
6
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Spring Framework 5
• Reactive Spring
• Functional APIs
• Kotlin support
7
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Spring Framework 5
• Reactive Spring
• Functional APIs
• Kotlin support
8
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
9
😀
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
10
😱 🐌
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
Blocking
• Large thread pool required
• Each request gets its own thread
Non-Blocking
• Small thread pool
• Worker threads process events
11
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
Servlet Stack
• Servlet container
• Servlet API
• Spring MVC
Reactive Stack
• Netty, Servlet 3.1, Undertow
• Reactive HTTP layer (Reactive Streams)
• Spring WebFlux
12
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
13
Mono<T> Flux<T>
Reactive Streams
Project Reactor
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ 14
Demo
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Reactive Spring
• Non-blocking
• Event driven at the center
• More for scalability than speed
• You can still use Spring MVC
15
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Spring Framework 5
• Reactive Spring
• Functional APIs
• Kotlin support
16
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Functional APIs
17
RouterFunction<?> route = route(GET("/person/{id}"),
request -> {
Mono<Person> person = Mono.justOrEmpty(request.pathVariable("id"))
.map(Integer::valueOf)
.then(repository::getPerson);
return ServerResponse.ok().body(fromPublisher(person, Person.class));
})
.and(route(GET("/person"),
request -> {
Flux<Person> people = repository.allPeople();
return ServerResponse.ok().body(fromPublisher(people, Person.class));
}))
.and(route(POST("/person"),
request -> {
Mono<Person> person = request.body(toMono(Person.class));
return ServerResponse.ok().build(repository.savePerson(person));
}));
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Spring Framework 5
• Reactive Spring
• Functional APIs
• Kotlin Support
18
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Changed
• Configuration properties
• Gradle plugin
• Actuator endpoints
19
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Changed
• Configuration properties
• Gradle plugin
• Actuator endpoints
20
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Configuration Properties
• Relaxed binding rules stay the same
• Uniform format for reading properties from the environment
• Elements separated by dots
• Must be alpha-numeric
• Must be lowercase
• Hyphen can be used to separate words
21
my.foo.hello-world
my.foo.helloWorld
my.foo.hello_world
my.foo.helloworld
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Configuration Properties
• Indices in environment variables
MY_VAR_1=a my.var[1]
MY_VAR_1_2=b my.var[1][2]
• Consistent behavior for Collections
• Better types, e.g. Duration “1s” “2m” “5d”
• Origin support
22
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ 23
Demo
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Changed
• Configuration properties
• Gradle plugin
• Actuator endpoints
24
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Gradle Plugin
•bootRepackage replaced by bootJar & bootWar
• Tasks do not figure out what to do
• Plugin configures the tasks with sensible defaults
• Reacts to other plugins
• Explicit dependency management
25
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Changed
• Configuration properties
• Gradle plugin
• Actuator endpoints
26
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Actuator Endpoints
• Endpoint annotations
•@Endpoint, @WebEndpoint, @JmxEndpoint
• Tech independent operations
•@ReadOperation, @WriteOperation, @DeleteOperation
• Tech specific extensions
•@EndpointWebExtension, @EndpointJmxExtension
27
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Actuator Endpoints
• Works with:
• Spring MVC
• Jersey
• Spring WebFlux
• Reactive health indicators
28
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Evolving
• Metrics
• Security
29
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Evolving
• Metrics
• Security
30
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Metrics
• Auto-configuration for metrics instrumentation by Micrometer *
• Hierarchical metrics replaced by dimensional metrics
• Facade over multiple monitoring systems
31
* Introducing Micrometer Application Metrics - (Thursday 10:30am)
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
What’s Evolving
• Metrics
• Security
32
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Security
• Simpler security auto-configuration
• Auto-configuration backs-off easily
• Adding custom security is easy
• No ordering issues with WebSecurityConfigurerAdapter
• RequestMatchers for static resources and actuators
• Web actuator endpoints have consistent behavior
33
Unless otherwise indicated, these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons
Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/
Security
• OAuth 2.0
• Moving to Spring Security 5.0
• Support for multiple client registrations
• Authorization server/Resource server support
34
Questions?
@madhurabhave23
@phillip_webb
#springone@s1p
https://github.com/mbhave/webflux-demo
https://github.com/mbhave/actuator-demo
https://github.com/mbhave/configuration-properties-demo

What's new in Spring Boot 2.0

  • 1.
    A Sneak Peekat Spring Boot 2.0 By Madhura Bhave / Phil Webb @madhurabhave23 / @phillip_webb 1
  • 2.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Agenda • What’s New • Infrastructure upgrades • Spring Framework 5 • What’s Changed • Configuration properties • Gradle plugin • Actuator endpoints • What’s Evolving • Security • Metrics 2
  • 3.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s New • Infrastructure upgrades • Spring Framework 5 3
  • 4.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s New • Infrastructure upgrades • Spring Framework 5 4
  • 5.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Infrastructure Upgrades 5 8+ 8+ 5.23
  • 6.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s New • Infrastructure Upgrades • Spring Framework 5 6
  • 7.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Spring Framework 5 • Reactive Spring • Functional APIs • Kotlin support 7
  • 8.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Spring Framework 5 • Reactive Spring • Functional APIs • Kotlin support 8
  • 9.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring 9 😀
  • 10.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring 10 😱 🐌
  • 11.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring Blocking • Large thread pool required • Each request gets its own thread Non-Blocking • Small thread pool • Worker threads process events 11
  • 12.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring Servlet Stack • Servlet container • Servlet API • Spring MVC Reactive Stack • Netty, Servlet 3.1, Undertow • Reactive HTTP layer (Reactive Streams) • Spring WebFlux 12
  • 13.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring 13 Mono<T> Flux<T> Reactive Streams Project Reactor
  • 14.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ 14 Demo
  • 15.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Reactive Spring • Non-blocking • Event driven at the center • More for scalability than speed • You can still use Spring MVC 15
  • 16.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Spring Framework 5 • Reactive Spring • Functional APIs • Kotlin support 16
  • 17.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Functional APIs 17 RouterFunction<?> route = route(GET("/person/{id}"), request -> { Mono<Person> person = Mono.justOrEmpty(request.pathVariable("id")) .map(Integer::valueOf) .then(repository::getPerson); return ServerResponse.ok().body(fromPublisher(person, Person.class)); }) .and(route(GET("/person"), request -> { Flux<Person> people = repository.allPeople(); return ServerResponse.ok().body(fromPublisher(people, Person.class)); })) .and(route(POST("/person"), request -> { Mono<Person> person = request.body(toMono(Person.class)); return ServerResponse.ok().build(repository.savePerson(person)); }));
  • 18.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Spring Framework 5 • Reactive Spring • Functional APIs • Kotlin Support 18
  • 19.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Changed • Configuration properties • Gradle plugin • Actuator endpoints 19
  • 20.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Changed • Configuration properties • Gradle plugin • Actuator endpoints 20
  • 21.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Configuration Properties • Relaxed binding rules stay the same • Uniform format for reading properties from the environment • Elements separated by dots • Must be alpha-numeric • Must be lowercase • Hyphen can be used to separate words 21 my.foo.hello-world my.foo.helloWorld my.foo.hello_world my.foo.helloworld
  • 22.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Configuration Properties • Indices in environment variables MY_VAR_1=a my.var[1] MY_VAR_1_2=b my.var[1][2] • Consistent behavior for Collections • Better types, e.g. Duration “1s” “2m” “5d” • Origin support 22
  • 23.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ 23 Demo
  • 24.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Changed • Configuration properties • Gradle plugin • Actuator endpoints 24
  • 25.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Gradle Plugin •bootRepackage replaced by bootJar & bootWar • Tasks do not figure out what to do • Plugin configures the tasks with sensible defaults • Reacts to other plugins • Explicit dependency management 25
  • 26.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Changed • Configuration properties • Gradle plugin • Actuator endpoints 26
  • 27.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Actuator Endpoints • Endpoint annotations •@Endpoint, @WebEndpoint, @JmxEndpoint • Tech independent operations •@ReadOperation, @WriteOperation, @DeleteOperation • Tech specific extensions •@EndpointWebExtension, @EndpointJmxExtension 27
  • 28.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Actuator Endpoints • Works with: • Spring MVC • Jersey • Spring WebFlux • Reactive health indicators 28
  • 29.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Evolving • Metrics • Security 29
  • 30.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Evolving • Metrics • Security 30
  • 31.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Metrics • Auto-configuration for metrics instrumentation by Micrometer * • Hierarchical metrics replaced by dimensional metrics • Facade over multiple monitoring systems 31 * Introducing Micrometer Application Metrics - (Thursday 10:30am)
  • 32.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ What’s Evolving • Metrics • Security 32
  • 33.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Security • Simpler security auto-configuration • Auto-configuration backs-off easily • Adding custom security is easy • No ordering issues with WebSecurityConfigurerAdapter • RequestMatchers for static resources and actuators • Web actuator endpoints have consistent behavior 33
  • 34.
    Unless otherwise indicated,these slides are © 2013 -2017 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by -nc/3.0/ Security • OAuth 2.0 • Moving to Spring Security 5.0 • Support for multiple client registrations • Authorization server/Resource server support 34
  • 35.

Editor's Notes