Skip to content
Advertisement

Connecting to mongoDB in spring boot causes errors

I want to connect to mongoDB Atlas in a spring boot project, but always Exceptions are thrown. If I use Java without spring boot, everything works fine. The following test project reproduces the errors. The pom.xml:

JavaScript

The Main-class:

JavaScript

And the configuration for mongoDB:

JavaScript

The uri for mongoDB is stored in application.properties. If I start the server, the following exeception is thrown:

JavaScript

Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

So I have tried to disable ssl through adding to the uri: &ssl=false However, then another exception is thrown:

JavaScript

I have found unfortunately no solution to solve them. Has someone encountered the same problem or knows a solution? Thank you

Advertisement

Answer

For everyone having the same problem: the cause was, that there were different versions in the maven repo. So mvn clean and mvn install solved the problem.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement