<개요>

- 신규 프로젝트 진행시 Spring Boot 3.2 를 사용하기 위해서 공통 프로젝트 생성

- 기존 프로젝트와도 호환성 및 추후 유지보수를 위해서 버전을 올리기로 결정

(엊그제 시작했던 것 같은데 벌써 Support 기간이 끝난 Legacy 가 되어감.. 버전업 속도가 참 빠르다)

- 연계되어 있는 Artifact들이 많고 Compatibility를 확인해야 함 (JDK버전까지 고려해야 함)

Spring Cloud AWS Spring Cloud Spring Boot Spring Framework AWS Java SDK
2.3.x (maintenance) 2020.0.x (3.0) 2.4.x, 2.5.x 5.3.x 1.x
2.4.x (maintenance) 2021.0.x (3.1) 2.6.x, 2.7.x 5.3.x 1.x
3.0.x 2022.0.x (4.0) 3.0.x, 3.1.x 6.0.x 2.x
3.1.x 2023.0.x (4.0) 3.2.x 6.1.x 2.x

 

<내용>

  • Legacy Version
    • spring boot : 2.4.3
    • spring-cloud : 2020.0.2
    • spring-cloud-aws : 2.3.0
    • aws sdk v1, v2
  • Target Version
    • spring boot : 3.2.4
    • spring-cloud : 2023.0.0
    • spring-cloud-aws : 3.1.1
    • aws sdk v2
  1. Code변경사항
    • Spring 6.x
      1. 패키지명
        1. javax → jakarta
      2. Security Config
        1. cors, httpBasic, csrf, antMatchers
          1. depreacted 메소드 수정 및 주입방식 변경
      3. jakarta.annotation.PostConstruct
        1. tomcat-annotations추가가 필요한데 버전은 추가 확인할 필요가 있다.
      4. HttpStatus::is4xxClientError
        1. HttpStatusCode::is4xxClientError 변경
      5. java.lang.NoSuchMethodError: 'void org.springframework.util.Assert.notNull(java.lang.Object)’
        1. spring boot parent만 사용하고 참조라이브러리들 특정버전을 명시하는 것은 삼가한다.
        2. jasypt의 경우 spring 내부 encrypt를 사용하는 것으로 점차 변경할 예정.
      6. PagingAndSortingRepository 가 더이상 CrudRepository를 상속하지 않기 때문에 추가필요
    • Hibernate
      1. Unable to load class [org.hibernate.dialect.MySQL57Dialect]
        1. org.hibernate.dialect.MySQLDialect 로 변경
      2. Alias [creationDateTime] is already used in same select clause [position=4]
        1. 중복되는 컬럼이 있는지 체크하는 부분이 추가됨
      3. spring.datasource.initialization-mode=always is deprecated.
      4. spring: jpa: defer-datasource-initialization: true sql: init: mode: always data-locations: classpath:data-local.sql
      5. Custom으로 작성한 쿼리에서 간혹 자동 생성Count쿼리에 문제가 발생하는 경우가 있다.  기본 Select 문법에 대한 수정이 필요함 (e.g Alias 등)
    • Swagger 변경 (기존 Swagger 2안에 javax 패키지 참조로 오류가 발생하여 변경이 필요함)
      1. maven 변경
      <dependency>    
      	<groupId>org.springdoc</groupId>    
      	<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>    
      	<version>2.0.2</version></dependency>
      <dependency>
          <groupId>io.swagger</groupId>
          <artifactId>swagger-annotations</artifactId>
          <version>1.5.20</version>
      </dependency>
      
    • MySQL
      • <dependency>
      • <groupId>com.mysql</groupId>
      • <artifactId>mysql-connector-j</artifactId>
      • </dependency>
    • AWS SDK V2
      1. 상세 사용법은 AWS Documentation을 참고하여 수정함
    • Spring Security
      • WebFlux SecurityWebFilterChain
        • 기존에는 @Configuration이 없어도 동작했었으나 반드시 필요함
      • 테스트를 위한 Bean 생성 및 방법
@RunWith(SpringRunner.class)
@WebMvcTest(Controller.class )
@Import(SecurityConfig.class)
@ContextConfiguration(classes = SpringSecurityWebAuthTestConfig.class)
public class ControllerTest { 
	@Test @WithUserDetails("admin")
@TestConfiguration
@EnableWebSecurity
public class SpringSecurityWebAuthTestConfig { 
	@Bean 
    @Primary 
    public UserDetailsService userDetailsService() { 
    List<SimpleGrantedAuthority> userAuth = new ArrayList<>(); 
    userAuth.add(new SimpleGrantedAuthority("ROLE_USER")); 
    List<SimpleGrantedAuthority> adminAuth = new ArrayList<>(); 
    adminAuth.add(new SimpleGrantedAuthority("ROLE_ADMIN")); 
    
    LoginUserDetails loginUserDetails = new LoginUserDetails(-1, "", "user","", userAuth); 
    LoginUserDetails loginAdminDetails = new LoginUserDetails(-1, "", "admin", "", adminAuth); 
    
    return new CustomInMemoryUserDetailsManager(Arrays.asList(loginUserDetails, loginAdminDetails)); 
}

 

- 참조 사이트

https://github.com/awspring/spring-cloud-aws?tab=readme-ov-file#compatibility-with-spring-project-versions

 

GitHub - awspring/spring-cloud-aws: The New Home for Spring Cloud AWS

The New Home for Spring Cloud AWS. Contribute to awspring/spring-cloud-aws development by creating an account on GitHub.

github.com

https://spring.io/projects/spring-boot#support

 

Spring Boot

 

spring.io

https://docs.aws.amazon.com/ko_kr/sdk-for-java/latest/developer-guide/migration-whats-different.html

 

AWS SDK for Java 1.x와 2.x의 차이점은 무엇입니까? - AWS SDK for Java 2.x

SDK 1.x의 여러 패키지 이름에는 다음이 포함됩니다. v2 이 v2 경우에 를 사용한다는 것은 일반적으로 패키지의 코드가 서비스 버전 2에서 작동하도록 타겟팅되었음을 의미합니다. 전체 패키지 이

docs.aws.amazon.com

https://github.com/aws/aws-sdk-java-v2/blob/master/docs/LaunchChangelog.md#411-s3-operation-migration

 

aws-sdk-java-v2/docs/LaunchChangelog.md at master · aws/aws-sdk-java-v2

The official AWS SDK for Java - Version 2. Contribute to aws/aws-sdk-java-v2 development by creating an account on GitHub.

github.com

https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.0:-Hibernate-ORM-5-to-6-migration

 

Migration Guide 3.0: Hibernate ORM 5 to 6 migration

Quarkus: Supersonic Subatomic Java. . Contribute to quarkusio/quarkus development by creating an account on GitHub.

github.com

https://docs.spring.io/spring-boot/docs/3.2.4/reference/html/dependency-versions.html

 

Dependency Versions

 

docs.spring.io

 

+ Recent posts