gpt4 book ai didi

java - Mongodb 非法访问异常

转载 作者:可可西里 更新时间:2023-11-01 09:56:33 26 4
gpt4 key购买 nike

您好,我在 sping 中有这个配置。

启动 webapplication 后弹出以下异常:

07:04:54,336 DEBUG ctory.support.DefaultListableBeanFactory: 221 - 创建单例 bean 'mongo' 的共享实例

07:04:54,336 DEBUG ctory.support.DefaultListableBeanFactory: 450 - 创建 bean 'mongo' 的实例

07:04:54,337 DEBUG 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.springframework.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)

Caused by: java.lang.IllegalAccessError: tryed to access method org.bson.types.ObjectId.(III)V 从类 com.mongodb.Bytes 在 com.mongodb.Bytes.(Bytes.java:219) 在 com.mongodb.MongoOptions.reset(MongoOptions.java:75) 在 com.mongodb.MongoOptions.(MongoOptions.java:37)

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

代码在这里

有没有人知道,哪里出了问题?

最佳答案

已解决:

Maven 依赖

    <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>

这会导致 IllegalAccessError。

关于java - Mongodb 非法访问异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30930500/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com