0

我是春天的新手。我制作了 pom.xml 并在 pom.xml 文件中收到以下错误:

cvc-complex-type.2.4.a:发现以元素“存储库”开头的无效内容。'{" http://maven.apache.org/POM/4.0.0 ":dependency}' 之一是预期的。

我的 pom.xml 代码如下:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>packagename</groupId>
    <artifactId>projectname</artifactId>
    <packaging>war</packaging>
    <version>1.0</version>
    <name>Project Name</name>
    <url>http://maven.apache.org</url>

    <properties>
        <org.springframework.version>3.2.1.RELEASE</org.springframework.version>
        <org.spring.security.version>3.1.2.RELEASE</org.spring.security.version>
        <org.slf4j.version>1.6.1</org.slf4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.2.0.Final</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.moxy</artifactId>
        <version>2.5.0</version>
    </dependency>
    <!--- ADDED FOR TESTING-->
    <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-test</artifactId>  
            <version>${spring.version}</version>  
            <scope>test</scope>  
        </dependency>  
        <dependency>  
            <groupId>org.springframework</groupId>  
            <artifactId>spring-test-mvc</artifactId>  
            <version>1.0.0.M1</version>  
            <scope>test</scope>  
        </dependency>  

    <repositories>  
        <repository>  
            <id>org.springframework.maven.milestone</id>  
            <name>Spring Maven Milestone Repository</name>  
            <url>http://maven.springframework.org/milestone</url>  
        </repository>  
    </repositories>
    <!--- ADDED FOR TESTING END-->
    </dependencies>
    <build>
        <finalName>projectname</finalName>
        <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.0.4.v20130625</version>
        </plugin>
    </plugins>
    </build>
</project>
4

2 回答 2

2

您正在使用<repositories>inside <dependencies>,它应该彼此相邻。

将这些行向上移动大约 7 个位置:

<!--- ADDED FOR TESTING END-->
</dependencies>
于 2013-08-22T13:46:02.010 回答
-1

而不是包装你应该使用类型

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>packagename</groupId>
<artifactId>projectname</artifactId>
<type>war</type>
<version>1.0</version>
于 2013-08-22T13:42:24.243 回答