原因:java.lang.classnotfoundexception:org.springframework.data.mongodb.mongodatabasefactory

pkln4tw6  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(679)

我已经将springboot升级到2.3.8版本,现在在运行应用程序时出现以下错误,服务没有启动。

Caused by: java.lang.ClassNotFoundException: org.springframework.data.mongodb.MongoDatabaseFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:284)
    at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:324)
    ... 23 common frames omitted

以下是我使用的与mongodb相关的依赖项:

implementation "org.springframework.boot:spring-boot-starter-data-mongodb:2.3.0.RELEASE"
implementation "org.mongodb:mongo-java-driver:3.12.8"

更新

如果我正在添加以下依赖项,则应用程序将启动,但在使用crud存储库执行插入操作时失败:

implementation "org.springframework.data:spring-data-mongodb:3.0.0.RELEASE"

错误:

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: com.mongodb.client.MongoCollection.insertOne(Ljava/lang/Object;)Lcom/mongodb/client/result/InsertOneResult;
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    at com.davinta.commons.util.service.filter.GatewayAuthenticationTokenFilter.doFilter(GatewayAuthenticationTokenFilter.java:89)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题