Maven在導入其他項目時報錯:Plugin execution not covered by lifecycle configuration


這幾天想把Spring 攻略第二版完整的學習下,所以就在網上下載了該教材的源碼,尋思邊看書邊練習!之前有過一些Maven開發的相關經驗,覺得Maven在引入jar包上的配置還是很方便的,所以這次源碼的Maven配置我倒是不擔心,沒想到項目導入后就報了一堆錯誤,一個一個的去解決,很多問題網上都有解決辦法,就剩下一個問題折騰好久才解決掉,現將問題的解決過程記錄如下:

 1 問題描述

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-dependency-plugin:2.0:copy-dependencies (execution: copy-dependencies, phase: process-sources)

2 解決過程

在谷歌上面搜索——org.apache.maven.plugins:maven-dependency-plugin:2.0:copy-dependencies

點擊進入鏈接http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html

 

將上述代碼copy到項目的pom.xml文件中即可,代碼如下:

Copying project dependencies

Project dependencies are the dependencies declared in your pom. To copy them with their transitive dependencies, use the dependency:copy-dependencies mojo and configure the plugin like the sample below:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

  粘貼完代碼之后,選擇Maven——Update Project...

3 Missing artifact javax.transaction:jta:jar:1.0.1B解決辦法

就是本地maven庫中缺少了這個jar,需要把這個jar安裝到本地庫中去。

3.1 下載包含此jar的zip包,地址:

http://download.csdn.net/detail/spring123tt/6847843

3.2 cmd到zip包的目錄,運行下面的字符串

mvn install:install-file   -Dfile=./jta-1_0_1B-classes.zip   -DgroupId=javax.transaction   -DartifactId=jta -Dversion=1.0.1B   -Dpackaging=jar

 上述命令是把下載的jar包安裝在本地倉庫。

然后去update你的maven工程。就OK了!

4 在sts中導入舊的工程報錯處理

報錯如圖:

一共兩個問題,上面已經說明了解決過程。總的來說,需要在工程中引入兩個插件,在pom.xml中添加如下代碼:

<build>      
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                  <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                      <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                      <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
                      <overWriteReleases>false</overWriteReleases>
                      <overWriteSnapshots>false</overWriteSnapshots>
                      <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
        </plugins>
    </build>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM