0

我在 Eclipse 中玩耍,试图让 Maven 将依赖项加载到我的 Springs 项目中。我是 Maven 新手,所以这让我很难过。我试图强制 Maven2 将依赖项复制到 Eclipse 中的 target/lib 中,但不知道正确的方法。

我收到以下错误:

Description Resource    Path    Location    Type
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e.  pom.xml /TestSpringMaven    line 54 Maven Project Build Lifecycle Mapping Problem

这是我的 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>org.springsource.greenbeans.maven</groupId>
    <artifactId>TestSpringMaven</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>TestSpringMaven Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.webflow</groupId>
            <artifactId>spring-webflow</artifactId>
            <version>2.3.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>3.1.2.RELEASE</version>
        </dependency>

    </dependencies>
    <build>
        <finalName>TestSpringMaven</finalName>

        <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                            <executions>
                                <execution>
                                    <phase>install</phase>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                    <configuration>
                                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                    </configuration>
                                </execution>
                            </executions>
                    </plugin>
                </plugins>


    </build>

</project>
4

1 回答 1

0

Eclipse 自动在构建路径中包含 Maven 依赖项。确保你right click your project --> Maven --> Enable Dependency Management
的 jar 文件被自动复制到WEB-INF\lib\你的战争中。

如果你遵循 maven 默认设置,生活会容易得多。

于 2012-09-12T15:34:56.777 回答