1.

What is the difference between Spring Boot 1 & Spring Boot 2?

Answer»
  • Java VERSION: Spring Boot 2 requires Java 8 as a minimum version. Spring Boot 1 supports version Java 7 and below. From Spring Boot version 1.4.x, it requires Java 7 however lower versions of supports lower Java versions like Java 6 or so. As far as a recommendation goes, for Spring Boot 1, try to be at least on Java version 7 as much as possible. If you want to use the latest Java release and take advantage of this framework, Spring Boot 2 is the only option for you.
  • Spring Version: If you want to use features of Spring 5, go for Spring Boot 2.
  • BOM ( Bill of Materials): In Spring Boot 2, there has been an upgrade to the dependencies version, the whole list is available here, for example :
    • Gradle minimum version is 3.4
    • Tomcat - version 8.5
    • Hibernate - 5.2
  • Security upgrade

With Spring Boot2, everything is secured, actuator endpoints as well as static resources.

  • New Starters

New Starters for Reactive components like MongoDB, Redis, Cassandra.

  • Spring Boot Actuator Upgrade

All endpoints are now under /actuator endpoint. You can tweak this path by using management.endpoints.web.base-path property.

All are disabled by DEFAULT( except /health & /info) . To enable you can use management.endpoints.web.exposure.include=* ( or list endpoints to be enabled)

You can easily write a new endpoint using @Endpoint annotation and it will get listed under /actuator.

For example,

@Component @Endpoint(id = "newapp") public class NewAppEndpoint {     private Map<String, NewApp> newAppStore = new ConcurrentHashMap<>();     @ReadOperation     public Map<String, NewApp> newApps() {         return newAppStore;     }     @ReadOperation     public NewApp newApp(@SELECTOR String name) {         return newAppStore.get(name);     }     @WriteOperation     public void configureNewApp(@Selector String name, NewApp newApp) {         newAppStore.put(name, newApp);     }     @DeleteOperation     public void deleteNewApp(@Selector String name) {         newAppStore.remove(name);     }     public static class NewApp {         private Boolean enabled;     //Other properties & their Setter/Getters..     } }

SIMILARLY, we can use @EndPointWebExtension to extend an existing endpoint.

  • Other changes: Gradle Plugin upgrade, most of the configuration start with management.


Discussion

No Comment Found