Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Sneak Peek into Spring Boot 2.0

Madhura Bhave
February 23, 2018

A Sneak Peek into Spring Boot 2.0

Madhura Bhave

February 23, 2018
Tweet

More Decks by Madhura Bhave

Other Decks in Programming

Transcript

  1. SPRING BOOT 2.0 A SNEAK PEEK INTO @madhurabhave23

  2. AGENDA ▸ What’s New ✴ Infrastructure Upgrades ✴ Spring Framework

    5 ✴ Micrometer Support ▸ What’s Changed ✴ Configuration Properties ✴ Gradle Plugin ✴ Actuator Endpoints ✴ Security ▸ Migration
  3. WHAT’S NEW ▸ Infrastructure upgrades ▸ Spring Framework 5 ▸

    Micrometer Support
  4. INFRASTRUCTURE UPGRADES 8+ 8+ 5.2 3

  5. WHAT’S NEW ▸ Infrastructure upgrades ▸ Spring Framework 5 ▸

    Micrometer Support
  6. SPRING FRAMEWORK 5 ▸ Reactive Spring ▸ Functional APIs ▸

    Kotlin Support
  7. REACTIVE SPRING

  8. REACTIVE SPRING

  9. REACTIVE SPRING Blocking Non Blocking •Large thread pool required •Each

    request gets its own thread •Small thread pool •Worker threads process events
  10. REACTIVE SPRING Servlet Stack Reactive Stack •Servlet Container •Servlet API

    •Spring MVC •Netty, Servlet 3.1, Undertow •Reactive HTTP layer (Reactive Streams) •Spring WebFlux
  11. REACTIVE SPRING Project Reactor Flux<T> Mono<T> Reactive Streams

  12. DEMO

  13. REACTIVE SPRING ▸ Non-blocking ▸ Event loop at the center

    ▸ More for scalability than speed ▸ You can still use Spring MVC https://www.infoq.com/presentations/servlet-reactive-stack https://www.youtube.com/watch?v=Cj4foJzPF80
  14. SPRING FRAMEWORK 5 ▸ Reactive Spring ▸ Functional APIs ▸

    Kotlin Support
  15. FUNCTIONAL APIS 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)); }));
  16. SPRING FRAMEWORK 5 ▸ Reactive Spring ▸ Functional APIs ▸

    Kotlin Support https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0
  17. WHAT’S NEW ▸ Infrastructure upgrades ▸ Spring Framework 5 ▸

    Micrometer Support
  18. MICROMETER SUPPORT ▸ Auto-configuration for metrics instrumentation library - Micrometer

    ▸ Hierarchical metrics replaced by dimensional metrics ▸ Facade over multiple monitoring systems
  19. WHAT’S CHANGED ▸ Configuration properties ▸ Gradle plugin ▸ Actuators

    ▸ Security
  20. DEMO

  21. ▸ 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 CONFIGURATION PROPERTIES my.foo.hello-world my.foo.helloWorld my.foo.hello_world my.foo.helloworld
  22. ▸ Indices in environment variables ✴ my_foo_1 my.foo[1] ✴ my_foo_1_2

    my.foo[1][2] ‣ Consistent behavior for Collections ‣ Better types, e.g. Duration “1s” “2m” “5d” ‣ Origin support CONFIGURATION PROPERTIES
  23. WHAT’S CHANGED ▸ Configuration properties ▸ Gradle plugin ▸ Actuator

    Endpoints ▸ Security
  24. 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 https://www.youtube.com/watch?v=p3RmYA_HsMM
  25. WHAT’S CHANGED ▸ Configuration properties ▸ Gradle plugin ▸ Actuator

    Endpoints ▸ Security
  26. DEMO

  27. ACTUATOR ENDPOINTS ▸ Endpoint annotations ✴ @Endpoint, @WebEndpoint, @JmxEndpoint ▸

    Tech independent operations ✴ @ReadOperation, @WriteOperation, @DeleteOperation ▸ Tech specific extensions ✴ @EndpointWebExtension, @EndpointJmxExtension
  28. ACTUATOR ENDPOINTS ▸ Works with: ✴ Spring MVC ✴ Jersey

    ✴ Spring WebFlux ▸ Reactive Health Indicators ▸ Overhaul of the “/actuator/mappings” & “/actuator/trace” endpoints
  29. WHAT’S CHANGED ▸ Configuration properties ▸ Gradle plugin ▸ Actuator

    Endpoints ▸ Security
  30. 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 ▸ Auto-configuration for reactive security
  31. SECURITY ▸ OAuth 2.0 ✴ Moving to Spring Security 5.0

    ✴ Support for multiple client registrations ✴ Authorization Server/Resource Server support https://github.com/spring-projects/spring-security-oauth2-boot
  32. MIGRATION ▸ Migration guide in the Spring Boot Wiki ▸

    spring-boot-properties-migrator module
  33. THANKS! Questions? @madhurabhave23 mbhave@pivotal.io https://github.com/mbhave/webflux-demo https://github.com/mbhave/actuator-2.0-demo https://github.com/mbhave/configuration-properties-demo