我是这个概念的新手。我不明白错误是什么。 我在我的xml中使用与我的pom文件中相同的版本。 我想用spring设置mybatis(intellij) 我尝试搜索,所以如果你将标签添加到pom.xml,我可以自动下载该库并知道该设置是可行的。 我已经将[mybatis-3.4.5.jar]添加到了lib。
这是pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GRU</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<!-- MyBatis -->
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
</project>
这是错误消息:
invalid content was found starting with element ‘dependency’. One of "http://mavenapache.org/POM/4.0.0"parent,
http://maven.apache.org/POM/4.0.0":name, "http:/mavenapache.org/POM/400":description, "http://mavenapache.org/POM/4.0.0":url,
"http://mavenapache.org/POM/4.0.0":prerequisites, "http://mavenapache.org/POM/4.0.0":issueManagement,
"http://mavenapache.org/POM/4.0.0":ciManagment, "http://mavenapache.org/POM/4.0.0":inceptionYear,
"http://mavenapache.org/POM/4.0.0":mailingLists, "http://mavenapache.org/POM/4.0.0":developers,
“http://mavenapache.org/POM/4.0.0":contributors, "http://mavenapacheorg/POM/4.0.0":licenses, "http://mavenapache.org/POM/400":scm ,
“http://mavenapache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":build, "http://mavenapache.org/POM/400":profiles, “http://mavenapache.org/POM/4.0.0":modules, http://mavenapache.org/POM/4.0.0":repositories, “http://mavenapache.org/POM/4.0.0":plugin Repositories,"http://mavenapache.org/POM/400":dependencies, “http://mavenapache.org/POM/4.0.0":reports, http://mavenapache.org/POM/4.0.0":reporting, “http://mavenapache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement
http://mavenapache.org/POM/40.0.":properties)’ is expected.
答案 0 :(得分:1)
您想使用<dependencies>
并为每个库创建<dependency>
:
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<dependency>
<!-- MyBatis -->
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.8</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependencies>
答案 1 :(得分:1)
您已将所有依赖项放在单个<dependency>
标记中。他们每个人都应拥有自己的<dependency>
标记,并附在<dependencies>
标记中。例如:
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
<dependency>
...
</dependencies>