JavaBeat

  • Home
  • 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)
  • Privacy

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:

[code]
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
[/code]

the improved message would look like this:

[code]
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.
[/code]

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:

[code lang=”xml”]
<properties>
<hibernate.version>4.3.11.Final</hibernate.version>
</properties>
[/code]

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:

[code lang=”java”]
@JsonComponent
public class Example {
….
}
[/code]

@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:

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

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

 

Filed Under: Spring Framework Tagged With: Caffeine Cache, Couchbase, Deserializer, Hibernate 5, JAR Layout, JSON Serializer, Narayana Transaction Manager, Neo4j, Spring Framework 4.3, Spring Release, Third Party Libraries

Spring Framework 4.3 RC1 Released

April 10, 2016 by Krishna Srinivasan Leave a Comment

This week spring framework lead Juergen Hoeller has announced in their blog that Spring Framework 4.3 RC1 is released. As we are aware, Spring Framework 4.3 release will be the final release in the Spring 4 series. The next release will be Spring 5 which is a major update to spring framework with Java 9 support and introduction of the Reactive programming to spring framework.

The final release will be on June first week.

Spring Framework 4.3 Release

Let’s look at the new features added as part of the Spring 4.3:

Dependency Injection Improvements

  • @Autowired injection of Map/Collection beans and self-references
  • @Autowired on configuration class constructors has been added to this release
  • There is no requirement to declare @Autowired on a unique non-default constructor
  • ObjectProvider as a richer variant of an ObjectFactory handle
  • InjectionPoint/DependencyDescriptor as an injectable argument for @Bean methods

Spring MVC Improvements

  • Default processing of OPTIONS, HEAD, Allow and If-Unmodified-Since
  • Support for custom HTTP Vary configuration and HTTP Range on custom resources
  • Precomposed @GetMapping, @PostMapping, @RequestScope, @SessionScope etc
  • @RequestAttribute and @SessionAttribute as handler method arguments
  • Full support for Jackson 2.7’s new type resolution algorithm

Overall Framework Updates

  • Wider support for composed annotations and for placeholders/expressions in attributes
  • Richer programmatic metadata in core container exceptions
  • Component scanning in manifest-defined classpath entries
  • A background initialization option for bootstrapping JPA / Hibernate
  • A ‘sync’ flag on @Cacheable and support for the Caffeine cache provider

I will be covering the new features in my upcoming tutorials. If you wish to get latest updates on spring framework, please subscribe to our newsletter.

 

Filed Under: Spring Framework Tagged With: Caffeine cache provider, Spring Release

Spring Framework 4.2.5 Released

February 26, 2016 by Krishna Srinivasan Leave a Comment

Spring team has released it’s latest release Spring Framework 4.2.5. This release is part of the Spring Framework 4’s maintenance release. There are no major changes or features planned as part of this release. This release focus mainly on fixing the issues and providing more stability to the Spring 4 release.

It is highly recommended to upgrade to this release if you are using any of the 4.x release. This would solve any of the existing issues which your application has with Spring Framework.

Spring Framework 4.2.5

With the above announcement, spring team has also announced the release of Spring Framework 4.3.0.M1. This is next release and final release on 4.x series. Spring Framework 4.3.0 will have lot of new features and improvements. After this release, next stop will be the great Spring Framework 5. As you are aware, Spring 5 would have tons of goodies that is going to excite the Spring community.

Spring Framework Tutorials:

  • Complete Guide for Spring Boot
  • Spring Data JPA Tutorials
  • Spring Framework Books

 

Filed Under: Spring Framework Tagged With: Spring Release

Spring Framework 4.1 Announced

January 16, 2014 by Krishna Srinivasan Leave a Comment

Within one month after the major release of Spring 4, this week Spring IO team has announced their plan for their next release on Spring Framework 4.1. This new version would be available to the public by August 2014. It is expected that Release Candidate1 (RC1) will be made available from Jun 2014.As their blog mentions, there are few key themes to be covered as part of this release. The list of notable features that will be added to this release are:

  • Comprehensive web resource handling – resource pipelining, cache control refinements
  • Caching support revisited – aligned with JCache 1.0 final, user-requested enhancements
  • JMS support overhaul – aligned with our messaging module, annotation-driven endpoints
  • Performance improvements – application startup, SpEL expression evaluation

Also the above lists are not the fine one. There are many other features lined up for this release and they would consider any proposal to add new features. I will keep update the details here when ever there is more information from the Spring IO team. You can read the Spring 4 Tutorials.

Filed Under: Spring Framework Tagged With: Spring Release

Spring Security 3.2 Released

December 17, 2013 by Krishna Srinivasan Leave a Comment

Spring IO team has announced the Spring Security 3.2 release. There are couple of notable changes in this release are Java Configuration support, Improving security on CSRF attacks and click jacking and Servlet 3+ API support. As the list grows, there are plenty of minor API changes listed in their change notes. There are more than 150+ issues fixed in this release. Here I list down the important features added in this release with brief description. For more details on each features, please look at their
documentation.

1. Java Configuration Support

Java configuration is supported from Spring Security 3.1. With the 3.2 release, you can configure without XML configuration files. There is no need for any XML configurations and everything can be done only through Java configuration.

2. Cross Site Request Forgery (CSRF) Protection

CSRF attacks are very common in the banking attacks. Theser are happening because there is no different in the bank’s website request and hacker’s website. Spring security 3.2 adds Synchronizer Token Pattern to ensure that it is verified before giving access to the request. Hacker’s website can not generate these tokens.

3. Click Jacking Protection

Allowing your website to be added to a frame can be a security issue. For example, using clever CSS styling users could be tricked into clicking on something that they were not intending. Spring security 3.2 adds X-Frame-Options and X-XSS-Protection to protect from the click jacking.

4. Security HTTP Response Headers

Spring Security has mechanisms to make it convenient to add the more common security headers to your application. However, it also provides hooks to enable adding custom headers. The new release adds some more common headers to improve the security.

5. Spring MVC Integration

Spring security provides number of configurations to integrate to the Spring MVC. One can use @EnableWebMvcSecurity for enabling the spring MVC.The example code would look like this:

[code lang=”java”]
@Configuration
@EnableWebMvcSecurity
public class SecurityConfig {
// …
}
[/code]

6. Concurrency Support

From this release, sepring security supports the multi-threaded environment and giving access to the variables which is running outside the same thread.

7. Servlet 3.0+ Integration

There is list of methods in Servlet 3 is integrated to the latest release of spring security.

  • HttpServletRequest.authenticate(HttpServletRequest,HttpServletResponse)
  • HttpServletRequest.login(String,String)
  • HttpServletRequest.logout()
  • AsyncContext.start(Runnable)
  • Async Servlet Support

8. Servlet 3.1+ Integration

Also it supports the servlet 3.1 methods.

  • HttpServletRequest#changeSessionId()

Filed Under: Spring Framework Tagged With: Spring Release, Spring Security

Spring Framework 4.0 Release and Features

December 13, 2013 by Krishna Srinivasan Leave a Comment

It is finally here!!. On 12-December-2013, Spring IO has officially announced that Spring Framework 4.0 GA is available for the production use. Why there is lot of things to talk about Spring 4.0?. It is the major release after Spring 3.0 which has been released on 2009. Also Spring team has transformed to Spring IO with looking beyond just a Java framework, their road maps and projects are not just only for the Java developers, it is more a complete enterprise solution.

Coming back to the release of Spring 4.0, there is plenty of major changes introduced in this release. Here I summarize the prominent features.

Spring 4.0 New Features

1. Deprecated Methods and Packages 

With this new release, all the deprecated methods and packages are dropped and no more supported. This should be the challenging point for those who want to migrate their old spring applications to the new version. As a caution, if you are running the old spring application, then first thing to get rid of your deprecated APIs before migrating to the latest version.

Look at API Differences to know what is changed in new release.

2. Java 8 Support

This is the first version supports all the features of Java 8. Spring team proudly announces that they have fixed all the issues with the Java 8 compatibility and it is ready to use with Java 8 once Open JDK 8 is released on March 2014. Also another update is that, Spring 4.0 has increased the minimum recommendation to Java 6.0. Also it states that any new project recommended to use the Java 7.0 for their projects with Spring 4.0. It still supports the lower version Java 6 and 7 without any problem.

3. Java EE 6 and 7

Java EE 6 or above is now considered the baseline for Spring Framework 4, with the JPA 2.0 and Servlet 3.0 specifications being of most suitable. It is possible to run your application in Servlet 2.5, but it is recommended to use Servlet 3.0 environment.

4.Groovy Bean Definition DSL

It is possible to define Spring beans using Groovy DSL. We can use bean definitions at the bootstrap using Groovy. Read this API to get more details.

5. Spring Core Changes

There are lot of changes to the Spring’s core container.

  • The @Description annotation has been added for developers using Java-based configuration.
  • @Conditional is introduced to conditionally filtering the beans.
  • Beans can now be Ordered when they are autowired into lists and arrays. Both the @Ordered annotation and Ordered interface are supported.
  • If you are using Spring’s annotation support, you can now write custom annotations that expose specific attributes from the source annotation.

There are much more improvements, I will continue writing in this blog about the new features.

6. Spring Web Module Features

  • Most recommended is Servlet 3.0+ environment. If you are using Spring Testing Framework, then Servlet 3.0 compatible JAR is should be in your test classpath.
  • There is new @RestController annotation for defining the REST web services. This has the built-in @ResponseBody attribute. This is a specialized version of @Controller.
  • Spring provides comprehensive timezone support when developing Spring MVC applications.

7. Testing Features

There are several new features introduced for unit testing and integration testing.

  • Almost all the annotations in the spring-test module can now be used as meta-annotations to create custom composed annotations and reduce configuration duplication across tests.
  •  org.springframework.mock.web package is compatible with Servlet 3.0 .

The above features are only the few of them, I will come up with detailed tutorials on each features. Please subscribe here.

Filed Under: Spring Framework Tagged With: Spring 4 Tutorials, Spring Release

Spring Framework 4.0 RC1 Released

November 5, 2013 by Krishna Srinivasan Leave a Comment

Spring Framework 4.0 Release Candidate 1 is released by Spring IO this week. Earlier they have announced that Spring 4.0 is due to the release in October 2014. However, in the latest blog post they have indicated that it will be available by December 2014. The last addition of new features with this release candidate also included by them in this blog post. The documentation for the upcoming release is not yet reflecting the new version. It looks like we have to wait for the final release. Couple of weeks back, they have given the overview of the new features included in the Spring 4.0. Lets look at the list of new features added for this release candidate. This will be the final addition of the new features and this list will be moved to the final release.

  1. One of the most important theme for this (Spring 4.0) release is the compatibility of JDK 8.0, an upcoming Java version. With this release candidate, Spring framework offers out of the box support for the JDK 8.0 build.
  2. Support for the groovy based bean definitions.
  3. Auto wiring of spring beans using Generic types.
  4. using Objenesis to create CGLIB proxy instances (allowing for constructor injection).
  5. Support for JSR-223. It is scripting support for the Java platform. In the upcoming releases, Java platform will start adding support to the scripting languages out of the box.
  6. Time zone support in Spring MVC.
  7. More configuration options for the Spring MVC’s @ControllerAdvice.
  8. New API MvcUriComponentsBuilder is introduced with this release. It is keeping in mind with the release of Spring HATEOAS.
  9. Lot of fine tuning to the Spring’s Web Socket support.

It is the perfect time to start using the latest build. It is obvious that when release candidates are released, the build quality will be with good quality like in the production release. If you are an early adopter, lets jump start learning the latest version of spring framework.

Filed Under: Spring Framework Tagged With: Spring 4 Tutorials, Spring Release

Follow Us

  • Facebook
  • Pinterest

As a participant in the Amazon Services LLC Associates Program, this site may earn from qualifying purchases. We may also earn commissions on purchases from other retail websites.

JavaBeat

FEATURED TUTORIALS

Answered: Using Java to Convert Int to String

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Copyright © by JavaBeat · All rights reserved