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

    View full-size slide

  2. AGENDA
    ▸ What’s New
    ✴ Infrastructure Upgrades
    ✴ Spring Framework 5
    ✴ Micrometer Support
    ▸ What’s Changed
    ✴ Configuration Properties
    ✴ Gradle Plugin
    ✴ Actuator Endpoints
    ✴ Security
    ▸ Migration

    View full-size slide

  3. WHAT’S NEW
    ▸ Infrastructure upgrades
    ▸ Spring Framework 5
    ▸ Micrometer Support

    View full-size slide

  4. INFRASTRUCTURE UPGRADES
    8+ 8+
    5.2
    3

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. REACTIVE SPRING

    View full-size slide

  8. REACTIVE SPRING

    View full-size slide

  9. REACTIVE SPRING
    Blocking Non Blocking
    •Large thread pool required
    •Each request gets its
    own thread
    •Small thread pool
    •Worker threads process
    events

    View full-size slide

  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

    View full-size slide

  11. REACTIVE SPRING
    Project Reactor
    Flux
    Mono
    Reactive Streams

    View full-size slide

  12. 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

    View full-size slide

  13. SPRING FRAMEWORK 5
    ▸ Reactive Spring
    ▸ Functional APIs
    ▸ Kotlin Support

    View full-size slide

  14. FUNCTIONAL APIS
    RouterFunction> route = route(GET("/person/{id}"),
    request -> {
    Mono 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 people = repository.allPeople();
    return ServerResponse.ok().body(fromPublisher(people, Person.class));
    }))
    .and(route(POST("/person"),
    request -> {
    Mono person = request.body(toMono(Person.class));
    return ServerResponse.ok().build(repository.savePerson(person));
    }));

    View full-size slide

  15. SPRING FRAMEWORK 5
    ▸ Reactive Spring
    ▸ Functional APIs
    ▸ Kotlin Support
    https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0

    View full-size slide

  16. WHAT’S NEW
    ▸ Infrastructure upgrades
    ▸ Spring Framework 5
    ▸ Micrometer Support

    View full-size slide

  17. MICROMETER SUPPORT
    ▸ Auto-configuration for metrics instrumentation library -
    Micrometer
    ▸ Hierarchical metrics replaced by dimensional metrics
    ▸ Facade over multiple monitoring systems

    View full-size slide

  18. WHAT’S CHANGED
    ▸ Configuration properties
    ▸ Gradle plugin
    ▸ Actuators
    ▸ Security

    View full-size slide

  19. ▸ 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

    View full-size slide

  20. ▸ 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

    View full-size slide

  21. WHAT’S CHANGED
    ▸ Configuration properties
    ▸ Gradle plugin
    ▸ Actuator Endpoints
    ▸ Security

    View full-size slide

  22. 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

    View full-size slide

  23. WHAT’S CHANGED
    ▸ Configuration properties
    ▸ Gradle plugin
    ▸ Actuator Endpoints
    ▸ Security

    View full-size slide

  24. ACTUATOR ENDPOINTS
    ▸ Endpoint annotations
    ✴ @Endpoint, @WebEndpoint, @JmxEndpoint
    ▸ Tech independent operations
    ✴ @ReadOperation, @WriteOperation, @DeleteOperation
    ▸ Tech specific extensions
    ✴ @EndpointWebExtension, @EndpointJmxExtension

    View full-size slide

  25. ACTUATOR ENDPOINTS
    ▸ Works with:
    ✴ Spring MVC
    ✴ Jersey
    ✴ Spring WebFlux
    ▸ Reactive Health Indicators
    ▸ Overhaul of the “/actuator/mappings” & “/actuator/trace”
    endpoints

    View full-size slide

  26. WHAT’S CHANGED
    ▸ Configuration properties
    ▸ Gradle plugin
    ▸ Actuator Endpoints
    ▸ Security

    View full-size slide

  27. 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

    View full-size slide

  28. 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

    View full-size slide

  29. MIGRATION
    ▸ Migration guide in the Spring Boot Wiki
    ▸ spring-boot-properties-migrator module

    View full-size slide

  30. THANKS!
    Questions?
    @madhurabhave23 [email protected]
    https://github.com/mbhave/webflux-demo
    https://github.com/mbhave/actuator-2.0-demo
    https://github.com/mbhave/configuration-properties-demo

    View full-size slide