Migration to Spring Boot v3.0.0 How to

  1. Pom.xml changes
    1. Change spring-boot-starter-parent to 3.0.0
    2. Change the version of the artifact to the next major version
    3. Change java.version to 17
    4. Version for all dependencies and plugins must be provided as properties
    5. Use the latest version for all dependencies and plugins available in the Maven repository
    6. Openapi-generator-maven-plugin should contain the following configuration
      <generateSupportingFiles>true</generateSupportingFiles>
      <supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
      <configOptions>
        …
        <useSpringBoot3>true</useSpringBoot3>
        …
      </configOptions>
  2. All Java src
    1. All javax.servlet.* imports must be replaced with jakarta.servlet.*
    2. All javax.persistence.* imports must be replaced with jakarta.persistence.*
    3. All javax.validation.* imports must be replaced with jakarta.validation.*
    4. All javax.annotation.* imports must be replaced with jakarta.annotation.*
  3. spring.factories in src/main/resources/META-INF; If the file exists, remove org.springframework.boot.autoconfigure.EnableAutoConfiguration from the file and copy all the configuration into org.springframework.boot.autoconfigure.AutoConfiguration.imports in src/main/resources/META-INF/spring see: https://github.com/folio-org/folio-spring-base/blob/feature/FOLSPRINGB-81/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
  4. Jenkinsfile
    1. Change: buildNode = 'jenkins-agent-java17'
    2. healthChkCmd = 'wget --no-verbose --tries=1 --spider http://localhost:8081/admin/health || exit 1'
  5. Dockerfile
    1. Change: FROM folioci/alpine-jre-openjdk17:latest
    2. Add (for details see README):
      # Install latest patch versions of packages: https://pythonspeed.com/articles/security-updates-in-docker/
      USER root
      RUN apk upgrade --no-cache
      USER folio
  6. Application.yaml
    1. Add: spring.cloud.openfeign.okhttp.enabled = true if a project uses FeignClient
    2. Change: spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
  7. If a module uses PostgreSQL ENUMs
    1. pom.xml: add hypersistence-utils-hibernate-60 dependency see: https://github.com/folio-org/mod-password-validator/blob/feature/MODPWD-110/pom.xml#L88
    2. In entity classes replace @Type annotation with @Enumerated(EnumType.STRING) @Type(PostgreSQLEnumType.class) see: https://github.com/folio-org/mod-password-validator/blob/feature/MODPWD-110/src/main/java/org/folio/pv/domain/entity/PasswordValidationRule.java#L32
  8. If wiremock-jre8 is used
    1. pom.xml: add property <jetty.version>9.4.49.v20220914</jetty.version> see: https://github.com/folio-org/mod-password-validator/blob/feature/MODPWD-110/pom.xml#L40
  9. According to Spring Doc in Spring Boot 3.0.0 (from Spring Framework 5.8) WebSecurityConfigurerAdapter was deprecated and SecurityFilterChain was introduced.
    So WebSecurityConfigureAdapter must be removed and authorizeRequests() deprecated method changed to authorizeHttpRequests()

    https://docs.spring.io/spring-security/reference/5.8/migration/servlet/config.html#_stop_using_websecurityconfigureradapter (SecurityFilerChain)
    https://docs.spring.io/spring-security/reference/5.8/migration/servlet/config.html#use-new-requestmatchers (anyMatchers to requestMatchers)
    https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter