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. AGENDA ▸ What’s New ✴ Infrastructure Upgrades ✴ Spring Framework

    5 ✴ Micrometer Support ▸ What’s Changed ✴ Configuration Properties ✴ Gradle Plugin ✴ Actuator Endpoints ✴ Security ▸ Migration
  2. REACTIVE SPRING Blocking Non Blocking •Large thread pool required •Each

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

    •Spring MVC •Netty, Servlet 3.1, Undertow •Reactive HTTP layer (Reactive Streams) •Spring WebFlux
  4. 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
  5. 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)); }));
  6. SPRING FRAMEWORK 5 ▸ Reactive Spring ▸ Functional APIs ▸

    Kotlin Support https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0
  7. MICROMETER SUPPORT ▸ Auto-configuration for metrics instrumentation library - Micrometer

    ▸ Hierarchical metrics replaced by dimensional metrics ▸ Facade over multiple monitoring systems
  8. ▸ 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
  9. ▸ 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
  10. 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
  11. ACTUATOR ENDPOINTS ▸ Endpoint annotations ✴ @Endpoint, @WebEndpoint, @JmxEndpoint ▸

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

    ✴ Spring WebFlux ▸ Reactive Health Indicators ▸ Overhaul of the “/actuator/mappings” & “/actuator/trace” endpoints
  13. 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
  14. 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
  15. MIGRATION ▸ Migration guide in the Spring Boot Wiki ▸

    spring-boot-properties-migrator module