我是Java和Spring MVC的新手。我试图通过在pom.xml中使用以下代码来包含Spring Mongodb数据。
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
</dependency>
但是我得到了以下错误:
/ * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *** /
cvc-complex-type.2.4.a:从元素'dependency'开始发现无效内容。其中一个'{“http://maven.apache.org/POM/4.0.0":parent,,http://maven.apache.org/POM/4.0.0":description,"http:// maven .apache.org / POM / 4.0.0“:url,”http://maven.apache.org/POM/4.0.0":prerequisites,“http://maven.apache.org/POM/4.0.0 “:issueManagement,”http://maven.apache.org/POM/4.0.0":ciManagement,"http://maven.apache.org/POM/4.0.0":inceptionYear,"http:// maven .apache.org / POM / 4.0.0“:mailingLists,”http://maven.apache.org/POM/4.0.0":developers,"http://maven.apache.org/POM/4.0.0 “:贡献者,”http://maven.apache.org/POM/4.0.0":licenses,“http://maven.apache.org/POM/4.0.0":scm,"http:// maven .apache.org / POM / 4.0.0“:组织,”http://maven.apache.org/POM/4.0.0“:build,”http://maven.apache.org/POM/4.0.0 “:个人资料,”http://maven.apache.org/POM/4.0.0":modules,“http://maven.apache.org/POM/4.0.0”:存储库,“http:// maven .apache.org / POM / 4.0.0“:pluginRepositories,”http://maven.apache.org/POM/4.0.0":reports,"http://maven.apache.org/POM/4.0.0 “:报道,”http://maven.apache.org/POM/4.0.0“ :dependencyManagement,“http://maven.apache.org/POM/4.0.0":distributionManagement}”是预期的。
/ * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** /
这是我的pom.xml:
/ ############################################## ############################### / org.springframework 春天上下文 $ {org.springframework版本} 共享记录 共享记录 org.springframework 弹簧webmvc $ {org.springframework版本}
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.1.0.BUILD-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
/ ############################################## ############################## /
有人可以指导我做错了什么以及如何纠正。
提前致谢
答案 0 :(得分:1)
该错误表明您的pom.xml
有错误 - 它不遵循xml架构。
如果没有看到整个文件,说出确切的原因是很棘手的,但我猜你错过了开头<dependencies>
标签。
以下是the maven site的示例。
<project>
...
<properties>
<mavenVersion>2.1</mavenVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>${mavenVersion}</version>
</dependency>
</dependencies>
...
</project>