「已注销」 2016-03-29 03:47 采纳率: 80%
浏览 3279
已采纳

在控制台上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版本,这是怎么回事?

  • 写回答

4条回答 默认 最新

  • 再平凡也幸福 2016-03-29 05:31
    关注

    http://bbs.csdn.net/topics/380145658?page=1 希望这个网页可以帮到你

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧