
스프링 부트 실전 활용 마스터 책을 학습하던 중 de.flapdoodle.embed.mongo의 test 스코프 항목을 지우고
실행시키니 위와 같은 에러가 발생했다
property에 version을 명시하거나 embedded MongoDB을 사용 할 수 있도록 MongodConfig bean에 정의하라는 것
property에 version을 명시하고 싶은데 어떤 버전이 있는지 알 수 없어 구글링! 🥹
https://docs.spring.io/spring-boot/docs/current/reference/html/data.html#data.nosql.mongodb.embedded
Data
The Spring Framework provides extensive support for working with SQL databases, from direct JDBC access using JdbcTemplate to complete “object relational mapping” technologies such as Hibernate. Spring Data provides an additional level of functionality
docs.spring.io
스프링 문서를 보면 version 속성은 프로덕션에서 사용할 MongoDB의 버전과 일치하다고 나와있다!
Embedded Mongo Version 클래스에 나열된 대부분의 버전과 일부 버전에 접근 할 수 있다고 한다
아직 MongoDB를 설치하지 않아서 프로덕션 할 버전을 정하지 못했다 😁
https://www.mongodb.com/docs/manual/release-notes/
Release Notes — MongoDB Manual
www.mongodb.com
현재 Current Stable Release 이 5.0인걸로 확인되어 5.0.6로 적용해보기로 했다
application.yml에서
spring:
mongodb:
embedded:
version: 5.0.6
버전을 명시해주고 재실행하니
2022-06-29 00:53:11.002 INFO 23275 --- [ main] d.f.embed.mongo.MongodExecutable : start MongodConfig{version=Version{5.0.6}, timeout=de.flapdoodle.embed.mongo.config.Timeout@73fb1d7f, net=de.flapdoodle.embed.mongo.config.Net@73d4066e, cmdOptions=MongoCmdOptions{syncDelay=0, useDefaultSyncDelay=false, isVerbose=false, useNoPrealloc=true, useSmallFiles=true, useNoJournal=true, enableTextSearch=false, auth=false, master=false}, password=, userName=, replication=de.flapdoodle.embed.mongo.config.Storage@25d2f66, isConfigServer=false, isShardServer=false, processListener=de.flapdoodle.embed.mongo.config.processlistener.NoopProcessListener@5a2fa51f, params={}, args={}, pidFile=mongod.pid, supportConfig=de.flapdoodle.embed.mongo.config.SupportConfig@71945bc0}
실행되는 것을 확인했다
현재는 test 스코프를 제거 했지만
추후 테스트용으로 쓰려면 아래 문서를 참고해서 해봐야겠다!
https://www.baeldung.com/spring-boot-embedded-mongodb
Spring Boot Integration Testing with Embedded MongoDB | Baeldung
Learn how to use Flapdoodle's embedded MongoDB solution together with Spring Boot to run MongoDB integration tests smoothly.
www.baeldung.com
이와 같은 문제는 왜 발생했는가?
책의 버전은 2.4대이고 현재 2.7으로 진행해서 위와 같은 문제가 발생한 것이다
Spring Boot 2.6부터 spring.mongodb.embedded.version에는 auto-configured embedded MongoDB을 사용하도록 설정되어야 한다고 릴리스 정보에 언급되어 있다고 합니다!
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.6-Release-Notes#embedded-mongo
[참고]
@EnableAutoConfiguration(exclude =...) on tests failed in Spring Boot 2.6.0
I tried to upgrade my data-mongo example project to Spring Boot 2.6.0. There is a test designed to run against Testcontainers, I also included the embedded mongo dep for other tests, so I have to e...
stackoverflow.com
'IT > 기록' 카테고리의 다른 글
사용자 입력이 필요한 JUnit Test (0) | 2022.07.19 |
---|---|
Spring Boot DevTools 사용 (0) | 2022.07.04 |
Flutter I/O Extended Korea 2022에 다녀오다! (0) | 2022.06.28 |
[Flutter] 마스코트 귀여운 새! 이름은 무엇인가? (0) | 2022.06.27 |
[Ktor] Ktor는 뭘까? (0) | 2022.06.13 |