Over a million developers have joined DZone.

Spring Boot 1.4 Released

Some details on the newest features of Spring Boot, including new error messages and test improvements with Mockito integration.

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

One behalf of the Spring Boot team, and everyone that has contributed, I am pleased to announce that Spring Boot 1.4.0 has been released and is available now from repo.spring.io, Maven Central and Bintray. This release adds a significant number of new features and improvements and builds on the latest release of the Spring Framework. For full upgrade instructions and “new and noteworthy” features please see the release notes.

Here are some of the highlights of v1.4:

Startup Failure Message

Spring Boot will now perform analysis of common startup failures and provide useful diagnostic information rather than simply logging a stack trace. For example, if you have a port clash, you’ll now see the following message:

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

Convention-Based Error Pages

Custom error pages for a given status code can now be created by following a convention based approach. Simply add static HTML or a template in the correct location to create a mapping. For example, to register a custom 404 page you could add src/main/resource/public/error/404.html

Extended Data Support

Spring Boot now ships with support for Neo4J, Couchbase and Redis Spring Data repositories. In addition, Hibernate 5.0 is now the default JPA provider. We’ve also refreshed our Elasticsearch integration to support the Jest client.

Banner Images

You can now use image files to render ASCII art banners. Drop a banner.gif, banner.jpg or banner.png file into src/main/resources to have it automatically converted into ASCII:

Image Banner

Test Improvements

Spring Boot 1.4 includes a major overhaul of testing support. Test classes and utilities are now provided in dedicated spring-boot-test and spring-boot-test-autoconfigure jars. We’ve added AssertJ, JSONassert and JsonPath dependencies to the test starter and provided a simpler unified @SpringBootTest annotation for use with Spring’s JUnit runner.

We can now also auto-configure many tests, meaning most users will require less test configuration. We’ve also introduced dedicated @JsonTest, @WebMvcTest, @RestClientTest and @DataJpaTest annotations that let you quickly test a “slice” of your application.

Finally, there’s also comprehensive Mockto integration. You can now easily ‘mock’ or ‘spy’ Spring Beans:

@RunWith(SpringRunner.class)
@SpringBootTest
public class MyTest {

    @MockBean
    private RemoteService remoteService;

    @Autowired
    private Reverser reverser;

    @Test
    public void exampleTest() {
        // RemoteService has been injected into the reverser bean
        given(this.remoteService.someCall()).willReturn("mock");
        String reverse = reverser.reverseSomeCall();
        assertThat(reverse).isEqualTo("kcom");
    }

}

Actuator

The actuator /info endpoint has been improved so that you can easily contribute additional items. Out of the box we now support:

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

The /metrics endpoint has also been refined so that submissions can be “merged” and/or “grouped”.

Other Changes

There’s a whole host of other changes and improvements that are documented in the Release Notes. You can also find a list of deprecated classes and methods that we plan to remove in the next version.

We want to take this opportunity to again thank all our users and contributors. We’ve now had over 281 people submit code, and there have been over 8,500 commits to the project.

If you’re interested in helping out, check out the “ideal for contribution” tag in the issue repository. If you have general questions, please ask at stackoverflow.com using the spring-boot tag.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:
spring ,spring boot ,java ,mockito

Published at DZone with permission of Phil Webb. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}