2012-09-12 59 views
0

我在Eclipse中玩弄试图让Maven加载依赖项到我的Springs项目中..我是新来的maven,所以这给了我一个难时间。我试图迫使Maven2在eclipse中将依赖项复制到target/lib中,但不知道正确的方法。我在玩Spring,Maven和Eclipse,迫使Maven2复制依赖关系

我收到以下错误:

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> 
+0

你为什么特意试图让Maven复制这些库?如果您只是希望将它们部署或在编译类路径中使用它们,则不需要。 –

回答

0

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

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