프레임워크/Spring Boot
-
Spring boot 2.7.18에서 swagger 설정하기 <1>프레임워크/Spring Boot 2024. 1. 22. 19:45
프로젝트를 함께 만들고 있는 프론트엔드 개발자들과 효율적인 커뮤니케이션을 위해서 스웨거를 사용하려고 합니다. 적용하면 만난 이런 저런 이슈 사항들을 기록해보았습니다. 프로젝트 버전 spring boot: 2.7.18 springfox: 3.0.0 springdoc-openapi-ui: 1.7.0 요즘은 gpt에게 물어봐서 대략적인 흐름을 파악하고, 한 단계씩 검증하며 적용하는 방법으로 작업을 하는 것 같습니다. 아래 처럼 3단계면 된다고 하는데, 당연히 한번에 안될것이라 예상하고 가보겠습니다. 1. SpringFox 사용 Step1. 의존성 추가하기 아래의 의존성을 추가하기 전에 공식 홈페이지를 한번 찾아가봅니다. implementation 'io.springfox:springfox-boot-starte..
-
mongodb의 @Indexed 가 작동하지 않을 때프레임워크/Spring Boot 2023. 12. 24. 16:41
Entity에 @Indexed 어노테이션이 작동하지 않는 이슈를 해결하는 과정입니다. 아래는 Spring에서 선언한 Entity입니다. productId에 @Indexed(unique = true) 를 적용했음에도 DuplecateKeyError가 발생하지 않았습니다 @Document(collection="products") public class ProductEntity { @Id private String id; @Version private Integer version; @Indexed(unique = true) private int productId; 확인해보니 mongodb에 인덱스가 설정되지 있지 않았습니다 공식문서를 확인해보면 3.0 버전부터 의도하지 않은 impact를 방지하기 위해 명시적..
-
Junit5 에서 Junit4로 변경하기프레임워크/Spring Boot 2023. 12. 24. 14:44
1. 의존성 변경 스프링에서 junit 테스트를 실행하기 위해서는 아래와 같은 의존성을 추가해서 사용합니다. testImplementation 'org.springframework.boot:spring-boot-starter-test' 위 의존성은 Junit5를 기준으로 작동하게 되어있기 때문에 Junit4를 사용하고 싶으면 수정이 필요합니다. spring-boot-starter-test는 여러가지 패키지들을 조합해서 사용하는데, 대표 적으로 Junit5와 관련된 패키지는 아래와 같습니다. junit-jupiter junit-platform-commons 따라서 Junit4를 사용하고 싶다면 위의 패키지들을 제외하고, 추가로 Junit4를 의존성에 추가해주면 사용가능합니다. testImplementati..