Upgrade from Spring Boot 1.5 to 2.0

Source: Internet
Author: User

POM
    • 1.5
      <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.10.RELEASE</version><relativePath/></parent>
    • 2.0
      <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.3.RELEASE</version><relativePath/></parent>
Spring Data

Some methods of Spring data are renamed:

    • FindOne (ID), GetOne (ID)
    • Delete (ID), Deletebyid (ID)
    • Exists (ID), Existsbyid (ID)
    • FindAll (IDs), Findallbyid (IDS)
Configuration

When upgrading, you can add spring-boot-properties-migrator to the POM so that you will be prompted to change the configuration at startup:

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-properties-migrator</artifactId>    <scope>runtime</scope></dependency>

The major changes are security (the security auto-configuration is no longer customizable,a global security auto-configuration are now pro vided) and management parts.

    • Security
      The configuration and management.security at the beginning of security have expired, as the following configuration is no longer supported and needs to be adjusted to the code:
      security:ignored: /api-docs,/swagger-resources/**,/swagger-ui.html**,/webjars/**
    • Management
      management:security:enabled: falseport: 8090

      Modified to:

      management:server:port: 8090
    • DataSource
      datasource:initialize: false

      Modified to:

      datasource:initialization-mode: never

If you use PostgreSQL, you may get an error: Method Org.postgresql.jdbc.PgConnection.createClob () is not yet implemented hibernate, you need to modify the configuration:

jpa:    database-platform: org.hibernate.dialect.PostgreSQLDialect    properties:       hibernate:         default_schema: test         jdbc:           lob:             non_contextual_creation: true

For more parameters to adjust, see the reference document at the end of this article.

Security

Websecurityconfigureradapter

    • Security.ignored
      @Overridepublic void configure(WebSecurity web) throws Exception {web.ignoring().antMatchers("/api-docs", "/swagger-resources/**", "/swagger-ui.html**", "/webjars/**");}
    • AuthenticationManager
      If AuthenticationManager is injected into the code,
      @Autowiredprivate AuthenticationManager authenticationManager;

      Error at startup: Field AuthenticationManager required a bean of type ' Org.springframework.security.authentication.AuthenticationManager ' that could not being Found. Please add the following code to the Websecurityconfigureradapter:

      @Bean@Overridepublic AuthenticationManager authenticationManagerBean() throws Exception {return super.authenticationManagerBean();}
Actuator

The actuator access path has changed, and the word actuator ([/actuator/health],[/actuator/info]) is added to the front of the URL, which can be seen in the startup log.

Not to be continued ...

Reference documents

Spring Boot 2.0 Migration Guide
Spring Boot 2.0 Configuration Changelog
Spring Boot 2.0 new features and trends

Upgrade from Spring Boot 1.5 to 2.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.