当前位置: 首页 > 知识库问答 >
问题:

Mongodb IllegalAccessException

田博超
2023-03-14

嗨,我在sping有这个配置。

启动 Web 应用程序后,将弹出以下异常:

调试ctory.support.DefaultListableBeanFactory:221-创建单例bean'mongo'的共享实例

07:04:54336调试工厂支持。DefaultListableBeanFactory:450-创建bean“mongo”的实例

07:04:54,337调试ctory.support.DefaultListableBeanFactory: 523-急切地缓存bean'mongo'以允许解析潜在的循环引用

07:04:54,342 DEBUG ctory . support . defaultlistablebeanfactory:1616-在名为“mongo”的bean上调用afterPropertiesSet()

07:04:54,364 WARN context . support . xmlwebapplicationcontext:487-上下文初始化期间遇到异常-取消刷新尝试org . spring framework . beans . factory . beancreationexception:创建名为“mongo”的bean时出错:调用init方法失败;嵌套异常是java.lang.IllegalAccessError:试图从类com.mongodb.Bytes访问方法org.bson.types.ObjectId.(III)V

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)

at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)

at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)

at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)

at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)

at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)

at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1241)

at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041)

at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4944)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)

at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:581)

at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1683)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

导致原因:java.lang.IllegalAccessError:尝试访问方法org.bson.types.ObjectId。(三) 来自com.mongodb类的V。位于com.mongodb.MongoOptions.reset(MongoOptions.java:75)的com.mongodeb.Bytes(Bytes.java:219)的字节

at org.springframework.data.mongodb.core.MongoFactoryBean.createInstance(MongoFactoryBean.java:141)

at org.springframework.data.mongodb.core.MongoFactoryBean.createInstance(MongoFactoryBean.java:45)

at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
... 32 more

此处代码

有没有人有头绪,到底是哪里出了问题?

共有1个答案

荆修明
2023-03-14

解决:

马文依赖性

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
        <version>1.7.0.RELEASE</version>
    </dependency>

自动包含mongodb驱动程序2.13.0

我有依赖性

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver</artifactId>
    <version>3.0.2</version>
</dependency>

这会导致非法访问错误。

 类似资料:

相关问答

相关文章

相关阅读