<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div dir="ltr" style="text-align: justify;">
<div style="text-align: justify;">
On Last month May 17, 2016 spring boot team has announced the release of Spring Boot 1.4.0 M3. There is 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 This release closes over 150 issues and introduces a number of new features.</p>
<p><b>Highlights include:</b></p>
<ul>
<li>Lots of bug fixes and improvements over M2 (thanks to everyone for trying the milestones).</li>
<li>Convention based error pages (want a custom 404, just add <i><b>src/main/resources/public/error/404.html</b></i>).</li>
<li>Improved ErrorPage registration support.</li>
<li>Support for pluggable OAuth2 Principal extraction.</li>
</ul>
</div>
<h2 style="text-align: justify;"><b>New Features in Spring Boot 1.4</b></h2>
<div style="text-align: justify;">There are following new features of Spring Boot 1.4 Version release</div>
<div style="text-align: justify;"></div>
<ol>
<li>Executable JAR Layout</li>
<li>Startup error improvements</li>
<li>Hibernate 5</li>
<li>Spring Framework 4.3</li>
<li>Third Party Library</li>
<li>Custom JSON Serializer and Deserializer</li>
<li>New auto-configuration support
<ol>
<li> Couchbase</li>
<li> Neo4j</li>
<li> Narayana transactional manager</li>
<li> Caffeine Cache</li>
</ol>
</li>
<li>Actuator improvements</li>
<li>Testing improvements</li>
<li>Datasource binding</li>
<li>Image Banner</li>
<li>Summary</li>
</ol>
</div>
<h3><b>Executable JAR Layout</b></h3>
<p>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.</p>
<h3><b>Startup Error Improvements</b></h3>
<p>There is a 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 developer has to read the complete stack trace. But, latest release just shows the cause of the failure and what is the solution.</p>
<h3><b>Hibernate 5</b></h3>
<div style="text-align: justify;">If you have upgrade problems switching to Hibernate 5 can be postponed at a later stage by setting the hibernate.version in your pom.xml. Note though that the Spring team will not support Hibernate 4.3 from Spring Boot 1.4. So, it is advisable to upgrade to the latest hibernate versions immediately.</div>
<div style="text-align: justify;">If you want to still use the older version in your application, please add the following entries in your <b>pom.xml</b>:</div>
<pre class="highlight"><;properties>; 
 <;hibernate.version>;4.3.11.Final<;/hibernate.version>; 
<;/properties>; 
</pre>
<h3><b>Spring 4.3.0-RC1</b></h3>
<p>In Spring 4.3.0-RC1 there are lots of new features and enhancements. The full list you can find it <a href="https://dineshonjava.com/whats-new-in-spring-framework-4x/" target="_blank" rel="noopener">here</a>. (Also Read : <a href="https://dineshonjava.com/spring-4-tutorials-step-to-new-spring/" target="_blank" rel="noopener">Spring 4 Tutorials</a>).</p>
<h3><b>Third Party Libraries</b></h3>
<ul style="text-align: left;">
<li>Hibernate 5.1</li>
<li>Jackson 2.7</li>
<li>Solr 5.5</li>
<li>Spring Data Hopper</li>
<li>Spring Session 1.2</li>
<li>Hazelcast 3.6.</li>
</ul>
<h3><b>Custom JSON Serializer and Deserializer</b></h3>
<p>If you want to register a bean as the JSON components, then you can use @JsonComponent annotation as below:</p>
<pre class="highlight">@JsonComponent 
public class ModelData{ 
.... 
} 
</pre>
<h3><b>New Auto-Configuration Support</b></h3>
<p>Spring boot adds new auto configuration modules for every release. In this release also there are few more modules added to support the auto-configurations.</p>
<ul style="text-align: left;">
<li>Couchbase</li>
<li>Neo4j</li>
<li>Narayana Transaction Manager</li>
<li>Caffeine Cache</li>
</ul>
<h3><b>Actuator Improvements</b></h3>
<div style="text-align: justify;">There is a slight improvements on info endpoint information and metrics filter.</div>
<div style="text-align: justify;">Now you can register the InfoContributor interface to register the beans that expose the information to the info actuator endpoints.</div>
<p>The support provided for:</p>
<ul style="text-align: left;">
<li>Full or partial Git information generated from a build plugin</li>
<li>Build information generated from the Spring Boot Maven or Gradle plugin.</li>
<li>Custom information from the Environment (any property starting info.*)</li>
</ul>
<h3><b>Testing support</b></h3>
<p>The biggest change comes regarding testing support. There are two new modules spring-boot-test and spring-boot-test-autoconfigure</p>
<p><b>@SpringBootTest</b></p>
<div style="text-align: justify;">Spring already comes with great support for writing integration tests leveraging the spring-test module. The only problem might be that it uses lots of annotations (@SpringApplicationConfiguration, @ContextConfiguration, @IntegrationTest, @WebIntegrationTest) to accomplish it.</div>
<p>Spring Boot 1.4 tries to simplify this by providing a single @SpringBootTest annotation.</p>
<pre class="highlight">@RunWith(SpringRunner.class) 
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 
@Sql("/init-for-full-integration-test.sql") 
public class ApplicationTests { 
 
 @Autowired 
 private TestRestTemplate template; 
 
 @Test 
 public void random() { 
 ResponseEntity<;String>; fact = template.getForEntity("/", String.class); 
 
 assertThat(fact.getBody(), containsString("Chuck Norris sleeps with a pillow under his gun.")); 
 } 
} 
 
</pre>
<p>Here as you can see for convenience the injected TestRestTemplate is already configured to make calls against the started server, no need to inject the port with @Value(&#8220;${local.server.port}&#8221;). However if you would like to know the port there is a better @LocalServerPort annotation.</p>
<p><b>Testing slices of the application</b><br />
Sometimes you would like to test a simple “slice” of the application instead of auto-configuring the whole application. Spring Boot 1.4 introduces 3 new test annotations:</p>
<ul style="text-align: left;">
<li>@WebMvcTest &#8211; for testing the controller layer</li>
<li>@JsonTest &#8211; for testing the JSON marshalling and unmarshalling</li>
<li>@DataJpaTest &#8211; for testing the repository layer</li>
</ul>
<p><b>@WebMvcTest</b><br />
In order to test only the controller layer or often a single controller the @WebMvcTest used in combination with @MockBean can be handy. @Service or @Repository components will not be scanned.</p>
<pre class="highlight">@RunWith(SpringRunner.class) 
@WebMvcTest(ChuckNorrisFactController.class) 
public class CheckNorrisFactControllerTests { 
 
 @Autowired 
 private MockMvc mvc; 
 
 @MockBean 
 private ChuckNorrisFactService chuckNorrisFactService; 
 
 @Test 
 public void getOneRandomly() throws Exception { 
 given(chuckNorrisFactService.getOneRandomly()).willReturn(new ChuckNorrisFact("Chuck Norris counted to infinity twice.")); 
 
 mvc.perform(get("/").accept(MediaType.APPLICATION_JSON)) 
 .andExpect(status().isOk()) 
 .andExpect(content().json("{'fact':'Chuck Norris counted to infinity twice.'}")); 
 } 
} 
</pre>
<p><b>@JsonTest</b><br />
To test JSON marshalling and unmarshalling you can use the @JsonTest annotation. @JsonTest will auto-configure Jackson ObjectMappers and @JsonComponent beans</p>
<pre class="highlight">@RunWith(SpringRunner.class) 
@JsonTest 
public class ChuckNorrisFactJsonTests { 
 
 private JacksonTester json; 
 
 @Test 
 public void serialize() throws IOException { 
 ChuckNorrisFact fact = new ChuckNorrisFact("When Chuck Norris turned 18, his parents moved out."); 
 JsonContent write = this.json.write(fact); 
 
 assertThat(this.json.write(fact)).isEqualToJson("expected.json"); 
 } 
 
 @Test 
 public void deserialize() throws IOException { 
 String content = "{"fact":"Chuck Norris knows Victoria's secret."}"; 
 
 assertThat(this.json.parse(content)).isEqualTo(new ChuckNorrisFact("Chuck Norris knows Victoria's secret.")); 
 } 
} 
 
</pre>
<p><b>@DataJpaTest</b></p>
<p>To test the JPA layer of an application you can use @DataJpaTest. By default it configures an in-memory database, scans for @Entity classes and configures the Spring Data JPA repositories. @Service, @Controller, @RestController beans will not be loaded.</p>
<pre class="highlight">@RunWith(SpringRunner.class) 
@DataJpaTest 
public class ChuckNorrisFactRepositoryTests { 
 
 @Autowired 
 private TestEntityManager entityManager; 
 
 @Autowired 
 private ChuckNorrisFactRepository repository; 
 
 @Test 
 public void getOneRandomly() { 
 String fact = "If at first you don't succeed, you're not Chuck Norris."; 
 entityManager.persist(new ChuckNorrisFact(fact)); 
 
 List<;ChuckNorrisFact>; facts = repository.getOneRandomly(new PageRequest(0, 10)); 
 assertThat(facts.get(0).getText(), is(fact)); 
 } 
} 
 
</pre>
<h3><b>Datasource binding</b></h3>
<p>In Spring Boot 1.4 via spring.datasource property namespace only the common datasource properties are set. For datasource provider specific ones new namespaces were introduced.</p>
<pre class="highlight">spring.datasource.hikari.maximum-pool-size=5 
spring.datasource.hikari.connection-timeout=10 
</pre>
<h3><b><br />
</b> <b>Image Banners</b></h3>
<p>You can use an image to render the ASCII banner.</p>
<h2><b>Summary</b></h2>
<p>If you want to try out these new features and enhancements have a look to this <a href="https://github.com/spring-projects/spring-boot/issues?page=1&;q=milestone%3A1.4.0.M1" target="_blank" rel="noopener">github </a>repository.</p>
</div>
<div style="background-color: #f2f9fc; border-radius: 3px; border: 1px solid #c9e6f2; line-height: 1.45; padding: 16px;">
<p><b>Spring Boot Related Topics</b></p>
<ol style="text-align: left;">
<li><b><a href="https://dineshonjava.com/introduction-to-spring-boot-a-spring-boot-complete-guide/">Introduction to Spring Boo</a>t</b></li>
<li><a href="https://dineshonjava.com/essentials-key-components-and-internals-of-spring-boot-framework/"><b>Essentials and Key Components of Spring Boot</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-cli-installation-and-hello-world-example/"><b>Spring Boot CLI Installation and Hello World Example</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-initilizr-web-interface-and-examples/"><b>Spring Boot Initializr Web Interface</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-initilizr-with-ides-via-spring-tool-suite/"><b>Spring Boot Initializr With IDEs</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-initializr-with-spring-boot-cli/"><b>Spring Boot Initializr With Spring Boot CLI</b></a></li>
<li><a href="https://dineshonjava.com/installing-spring-boot/"><b>Installing Spring Boot</b></a></li>
<li><a href="https://dineshonjava.com/developing-your-first-spring-boot-application-hello-world/"><b>Developing your first Spring Boot application</b></a></li>
<li><a href="https://dineshonjava.com/customizing-spring-boot-auto-configuration/"><b>External Configurations for Spring Boot Applications</b></a></li>
<li><a href="https://dineshonjava.com/logging-configuration-in-spring-boot/"><b>Logging Configuration in Spring Boot</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-with-spring-mvc-application/"><b>Spring Boot and Spring MVC</b></a></li>
<li><a href="https://dineshonjava.com/working-with-sql-databases-in-spring-boot-application/"><b>Working with SQL Databases and Spring Boot</b></a></li>
<li><a href="https://dineshonjava.com/mysql-configuration-with-spring-boot/"><b>MySQL Configurations</b></a></li>
<li><a href="https://dineshonjava.com/spring-data-jpa-using-in-spring-boot-application/"><b>Spring Data JPA using Spring Boot Application</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-with-nosql-technologies/"><b>Spring Boot with NoSQL technologies</b></a></li>
<li><a href="https://dineshonjava.com/spring-cache-tutorial/"><b>Spring Cache Tutorial</b></a></li>
<li><a href="https://dineshonjava.com/spring-security-tutorial-using-spring-boot/"><b>Spring Security Tutorial with Spring Boot</b></a></li>
<li><a href="https://dineshonjava.com/spring-boot-and-mongodb-in-rest-application/"><b>Spring Boot and MongoDB in REST Application</b></a></li>
<li><b><a href="https://dineshonjava.com/spring-boot-actuator-complete-guide/">Complete Guide for Spring Boot Actuator</a></b></li>
<li><b><a href="https://dineshonjava.com/microservices-with-spring-boot/">Microservices with Spring Boot</a></b></li>
</ol>
</div>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/spring-boot-tutorial/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '148'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…