程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> 編碼-在控制台上maven打包報錯。

編碼-在控制台上maven打包報錯。

編輯:編程解疑
在控制台上maven打包報錯。

樓主剛看徐曉斌的《maven實戰》,正在控制台上鼓搗maven呢,mvn clean compile,mvn clean test也成功,然後mvn clean package打包也成功,但是由於打出來的Jar包沒有指定main方法的位置,我就按照書上的案例,加入maven-shade-plugin插件,在pom.xml加入這話話,一直打包都是錯誤的。
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>xx.xx.xxx</groupId>
  <artifactId>hello-maven</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

 <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <transformers>
         <transformer implementation = "org.apache.maven.plugins.shade.resource.MainifestResourceTransformer">
         <mainClass>xx.xxx.xxx.hellomaven.App</mainClass>
         </transformer>
      </transformers>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build> 
</project>

控制台報錯信息如下:

 [INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.731s
[INFO] Finished at: Tue Mar 29 11:40:17 CST 2016
[INFO] Final Memory: 10M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.2.1
:shade (default) on project hello-maven: Unable to parse configuration of mojo o
rg.apache.maven.plugins:maven-shade-plugin:1.2.1:shade: ClassNotFoundException:
Class name which was explicitly given in configuration using 'implementation' at
tribute: 'org.apache.maven.plugins.shade.resource.MainifestResourceTransformer'
cannot be loaded -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigur
ationException

~\m2\repository\org\apache\maven\plugins\maven-compiler-plugin
裡面居然是2.3.2版本,我的本地倉庫下載下載下來的不是指定的那個1.2.1版本,這是怎麼回事?

最佳回答:


http://bbs.csdn.net/topics/380145658?page=1 希望這個網頁可以幫到你

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved