Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect embedded mongodb when running tests #4

Open
alexandergabe opened this issue Dec 9, 2021 · 3 comments
Open

Cannot connect embedded mongodb when running tests #4

alexandergabe opened this issue Dec 9, 2021 · 3 comments

Comments

@alexandergabe
Copy link

I am on step 48. When running the test for findAll() I get an exception error stating "Set the spring.mongodb.embedded.version property or define your own MongodConfig bean to use embedded MongoDB". After doing some research, it appears I have to set the version. I tried creating an application.properties and using 'spring.mongodb.embedded.version = 5.05 ( or any other version, not sure which one to use.) and after running the test case again I get an error stating that I cannot download the embedded mongodb because the optional proxy is empty. I am unsure what that means and I cannot find a solution. Please help?

@Rajnish20
Copy link

You need to create a real collection in MongoDB or you can use embedded MongoDB and for that you need to use annotation for that and you need to setup dummy data before each test and for that you can use beforeEach method.
@activeprofiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebClient
You need to setup the profile as test and remember that this profiles must not be present in your yml file.

@safiadeo
Copy link

@Rajnish20 I'm having the same issue, I think that there is a mismatch between the mongo version from the Spring data starter and the version from the Embedded Mongo test dependency.

@safiadeo
Copy link

@alexandergabe II had the same exception as you

Caused by: java.lang.IllegalStateException: Set the spring.mongodb.embedded.version property or define your own MongodConfig bean to use embedded MongoDB

I fixed the issue by creating an application.yml file in the test package where I fixed the version of the embedded mongodb.
spring: mongodb: embedded: version: 3.4.11

felipem11 pushed a commit to felipem11/reactive-spring-webflux that referenced this issue Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants