• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

New Features in Spring Boot 1.4

April 14, 2016 //  by Krishna Srinivasan//  Leave a Comment

Last week spring boot team has announced the release of Spring Boot 1.4.0 M2. The final release is expected to be around next month. There is a lot of changes coming up in the new release. In this post, I am going to list down the summary of new features in spring boot 1.4. If you are interested in receiving the latest updates on spring boot, please subscribe here.

New features in Spring Boot 1.4

New Features in Spring Boot 1.4

Here is the table of contents for this tutorial:

  1. Executable JAR Layout
  2. Startup error improvements
  3. Hibernate 5
  4. Spring Framework 4.3
  5. Third Party Library
  6. Custom JSON Serializer and Deserializer
  7. New auto-configuration support
    1. Couchbase
    2. Neo4j
    3. Narayana transactional manager
    4. Caffeine Cache
  8. Actuator improvements
  9. Testing improvements
  10. Summary

1. Executable JAR Layout

If you are building the JAR file as an executable spring boot application, all the dependencies will be packaged under WEB-INF/lib and application’s own classes will be packages under root of the JAR file. But, spring boot 1.4.0 will package the dependencies under BOOT-INF/lib and application’s own classes under BOOT-INF/classes.

2. Startup Error Improvements

There is an improvement in displaying the useful error description on startup failures. Prior to 1.4.0, startup failures shows long stack trace that would not show the actual issue unless a developer has to read the complete stack trace. But, latest release just shows the cause of the failure and what is the solution.

If the problem is embedded servlet container’s port is being used by another service, the existing error message is like this:

2016-02-16 17:46:14.334 ERROR 24753 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.RuntimeException: java.net.BindException: Address already in use
    at io.undertow.Undertow.start(Undertow.java:181) ~[undertow-core-1.3.14.Final.jar:1.3.14.Final]
    at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainer.start(UndertowEmbeddedServletContainer.java:121) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:293) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
    at sample.undertow.SampleUndertowApplication.main(SampleUndertowApplication.java:26) [classes/:na]
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_60]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_60]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_60]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_60]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_60]
    at org.xnio.nio.NioXnioWorker.createTcpConnectionServer(NioXnioWorker.java:190) ~[xnio-nio-3.3.4.Final.jar:3.3.4.Final]
    at org.xnio.XnioWorker.createStreamConnectionServer(XnioWorker.java:243) ~[xnio-api-3.3.4.Final.jar:3.3.4.Final]
    at io.undertow.Undertow.start(Undertow.java:137) ~[undertow-core-1.3.14.Final.jar:1.3.14.Final]
    ... 11 common frames omitted

the improved message would look like this:

2016-02-16 17:44:49.179 ERROR 24745 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Embedded servlet container failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

3. Hibernate 5

Hibernate 5.1 is default persistent provider for the spring boot 1.4.0. If you are migrating from spring boot 1.3.0 to 1.4.0, then you will have to move from hibernate 4.3 to 5.1. Hibernate 4.3 will be supported only till the end of spring boot 1.4 versions, after that, it will not be supported. So, it is advisable to upgrade to the latest hibernate versions immediately.

  • Also Read: Spring and Hibernate Integration

If you want to still use the older version in your application, please add the following entries in your pom.xml:

<properties>
	<hibernate.version>4.3.11.Final</hibernate.version>
</properties>

4. Spring Framework 4.3

Spring Boot 1.4.0 requires and builds on spring framework 4.3. There is a lot of good features added as part of this release, you can read the summary of new features introduced in spring framework 4.3 (Also Read: Spring 4 Tutorials).

5. Third Party Libraries

List of third-party libraries that are upgraded to the latest version:

  • Hibernate 5.1
  • Jackson 2.7
  • Solr 5.5
  • Spring Data Hopper
  • Spring Session 1.2
  • Hazelcast 3.6.

6. Custom JSON Serializer and Deserializer

If you want to register a bean as the JSON components, then you can use @JsonComponent annotation as below:

@JsonComponent
public class Example {
....
}

@JsonComponent in the application, context will be automatically registered with Jackson.

7. New Auto-Configuration Support

Spring boot adds new auto configuration modules for every release. In this release also there are few more modules added to support the auto-configuration.

7.1. Couchbase

Couchbase is one of the popular NoSQL databases. Spring boot adds auto-configuration support for this database. Now you can easily access Bucket and Cluster bean by adding the spring-boot-starter-data-couchbase starter POM and adding a little more configuration:

spring.couchbase.bootstrap-hosts=my-host-1,192.168.1.123
spring.couchbase.bucket.name=my-bucket
spring.couchbase.bucket.password=secret

7.2. Neo4j

Auto-configuration support is added for the Neo4j database.

7.3. Narayana Transaction Manager

Auto-configuration support is now added for the Narayana transaction manager. You can choose between Narayana, Bitronix or Atomkos if you need JTA support.

7.4. Caffeine Cache

Auto-configuration is added for Caffeine v2.2. Existing Guava cache users should consider migrating to Caffeine as Guava cache support will be dropped in a future release.

8. Actuator Improvements

There are not many new features on the spring boot actuator modules for this release. There is a slight improvement on info endpoint information and metrics filter.

Now you can register the InfoContributor interface to register the beans that expose the information to the info actuator endpoints. The support provided for:

  • Full or partial Git information generated from a build plugin
  • Build information generated from the Spring Boot Maven or Gradle plugin.
  • Custom information from the Environment (any property starting info.*)

9. Test Improvements

Spring Boot 1.4 adds major improvements to the testing support. With the new release, all the test classes are moved to the dedicated spring-boot-test and spring-boot-test-autoconfigure.

@SpringBootTest annotation replaces the old,@SpringApplicationConfiguration@ContextConfiguration with the SpringApplicationContextLoader, @IntegrationTest or @WebIntegrationTest.

Spring Boot 1.4 introduces a number of specialized test annotations that can be used for testing specific parts of your application:

Spring Boot 1.4 introduces a number of specialized test annotations that can be used for testing specific parts of your application:

  • @JsonTest – For testing JSON marshaling and unmarshalling.
  • @WebMvcTest – For testing Spring MVC @Controllers using MockMVC.
  • @DataJpaTest – For testing Spring Data JPA elements

There are many other improvements that are not mentioned in the above list. I will be writing an in-depth analysis of each feature in the future tutorials. If you want to get the latest updates on spring boot, please subscribe here.

10. Summary

In this tutorial, I have summarized the list of new features that are added as part of spring boot 1.4 release. I have covered only the notable features, but there are many other minor improvements that are not explained here. Overall spring boot 1.4 is one of the major releases in spring boot with tons of improvements. If you are working on spring boot, please consider upgrading to the latest version.

Thank you for reading my blog!! Happy Learning!!

If you have any questions on spring boot, please write it in the comments section. If you are working on a spring project and looking for consultancy on spring boot implementation, please feel free to contact me. I will try my best to help you.

Reference:

  • Spring Boot Release Notes

 

Category: Spring FrameworkTag: Caffeine Cache, Couchbase, Deserializer, Hibernate 5, JAR Layout, JSON Serializer, Narayana Transaction Manager, Neo4j, Spring Framework 4.3, Spring Release, Third Party Libraries

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: «New Features in Spring Boot 1.4 Spring Framework 4.3 RC1 Released
Next Post: AngularJS : ng-maxlength and ng-minlength Directives AngularJS : ng-maxlength and ng-minlength Directives»

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact