Java Spring:mongodb连接问题

时间:2018-08-09 11:41:46

标签: java spring mongodb maven dependencies

我以前使用过这个spring-data-mongodb依赖项:

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

现在我更改为此依赖项:

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

现在我遇到以下错误:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/mongo]

违规资源:ServletContext资源[/WEB-INF/myServlet-servlet.xml]

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:301)

我无法执行单个查询。我该如何解决?

1 个答案:

答案 0 :(得分:0)

这是对我有用的依赖项:

{
"id":1,
"name":john,
"logs":[
   "log1",
   "log2",
   "log3"
   ]
}
{
"id":2,
"name":pete,
"logs":[
   "log3",
   "log2",
   "log3"
   ]
}
{
"id":3,
"name":steve,
"logs":[
   "log3",
   "log2",
   "log1"
   ]
}