Now Hiring: Are you an experienced and enthusiastic java developer?

Blog

New Features in Spring Boot 3.1: Streamlining Development and Management

New Features in Spring Boot 3.1: Streamlining Development and Management
Spring

New Features in Spring Boot 3.1: Streamlining Development and Management

Support for managing external services at development time using Testcontainers and Docker Compose

Testcontainers and Docker Compose are two popular tools for managing external services in development environments. With Spring Boot 3.1, you can use these tools to manage external services at development time, without having to worry about setting them up yourself.

  • Testcontainers and Docker Compose are now integrated with Spring Boot 3.1, allowing developers to effortlessly manage external services in their development environments.
  • By including the ‘spring-boot-starter-testcontainers’ dependency in your project, you gain access to these tools.
  • Integration tests can then utilize Testcontainers and Docker Compose to set up and utilize external services, such as a MySQL database running in a Docker container.

To use this feature, you will need to add the following dependency to your project:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-testcontainers</artifactId>
</dependency>

Once you have added this dependency, you can start using Testcontainers and Docker Compose in your integration tests. For example, the following code will start a MySQL database in a Docker container and use it in your integration test:

@SpringBootTest
@Testcontainers
class MyIntegrationTest {

    @Autowired
    private MySQLContainer mySqlContainer;

    @Test
    void test() {
        // Use the MySQL database in the Docker container
    }

}

Simplified configuration of Testcontainers in integration tests

In Spring Boot 3.1, you can now use a single property to configure Testcontainers in all of your integration tests. This property is called `spring.testcontainers.enabled`, and it can be set to `true` or `false`.

If you set this property to `true`, Testcontainers will be enabled for all of your integration tests. This means that all of your integration tests will be able to use Testcontainers to manage external services.If you set this property to `false`, Testcontainers will be disabled for all of your integration tests. This means that your integration tests will not be able to use Testcontainers to manage external services.

Centralized and expanded configuration of SSL trust material for connections

In Spring Boot 3.1, you can now configure SSL trust material in a single place. This place is the `spring.ssl.trust-store` property.

The `spring.ssl.trust-store` property can be used to specify the location of the trust store file. The trust store file is a file that contains the certificates of trusted CAs.

If you do not specify the `spring.ssl.trust-store` property, Spring Boot will use the default trust store file. The default trust store file is located in the `/etc/ssl/certs` directory.

Auto-configuration for Spring Authorization Server

In Spring Boot 3.1, Spring Boot provides auto-configuration for the Spring Authorization Server. This means that you can easily set up a Spring Authorization Server without having to write any configuration yourself.

To use the Spring Authorization Server auto-configuration, you will need to add the following dependency to your project:

<!-- wp:paragraph -->
<p>&lt;dependency&gt;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;spring-boot-starter-oauth2-authorization-server&lt;/artifactId&gt;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>&lt;/dependency&gt;</p>
<!-- /wp:paragraph -->

Once you have added this dependency, Spring Boot will automatically configure the Spring Authorization Server for you.

Improvements to the Docker Image Builder

The Docker Image Builder has been improved in Spring Boot 3.1 to make it easier to build Docker images for your Spring Boot applications.

One of the biggest improvements is the ability to use the `spring.build.docker.image` property to specify the name of the Docker image that you want to build. This property can be used to override the default name of the Docker image that is built by Spring Boot.

Another improvement is the ability to use the `spring.build.docker.buildArgs` property to specify build arguments that will be passed to the Docker build command. This can be used to customize the Docker image that is built by Spring Boot.Overall, the new features in Spring Boot 3.1 make it easier to develop, test, and deploy Spring Boot applications.

Leave your thought here

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