maven入门问题,打包的时候就报错了

maven入门问题,打包的时候就报错了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<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>com.imooc</groupId>
  <artifactId>maven-first</artifactId>
  <version>1.0.0-RELEASE</version>
  <repositories>
      <repository>
          <!-- 创建私服的地址 -->
          <id>aliyun</id>
          <name>aliyun</name>
          <url>https://maven.aliyun.com/repository/public</url>
      </repository>
  </repositories>
   
  <dependencies>
  <dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.17</version>
</dependency>
<dependency>
  <groupId>com.belerweb</groupId>
  <artifactId>pinyin4j</artifactId>
  <version>2.5.1</version>
</dependency>
  </dependencies>
  <build>
      <!-- 配置插件 -->
      <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-assembly-plugin</artifactId>
              <version>2.5.5</version>
              <!-- 用于说明在打包过程中的一些细节 -->
              <configuration>
                  <!-- 设置应用程序入口类,main方法 -->
                  <archive>
                      <manifest>
                          <mainClass>com.imooc.maven.PinYinTest</mainClass>
                      </manifest>
                  </archive>
                  <!-- 在打包过程中所使用的额外参数 -->
                  <descriptorRefs>
                      <!-- all in one,在打包时会将所引用的jar合并到输出的jar文件中 -->
                      <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
              </configuration>
          </plugin>
      </plugins>
  </build>
</project>
 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (make-assembly) on project maven-first: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single failed. NullPointerException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

http://img1.sycdn.imooc.com//climg/5d8b45d9098dbd9512110648.jpg

http://img1.sycdn.imooc.com//climg/5d8b45d909b6544713830567.jpg


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕阿满 2019-09-26 14:46:05

同学你好,建议同学去本地仓库中,将plugins目录下的文件,删除,如:

http://img1.sycdn.imooc.com//climg/5d8c5e7a09a75e7704300082.jpg

然后重新打包再试试。

祝:学习愉快~

好帮手慕阿满 2019-09-26 10:34:38

同学你好,建议同学替换pom文件中plugin的内容,替换为如下重新打包再试试。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<plugin>
     <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest><mainClass>com.imooc.maven.PinYinTest</mainClass></manifest>
        </archive>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

另外问一下同学在eclipse中,PinYinTest类可以正常运行吗?

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

  • 提问者 慕用1236393 #1
    还是不可以的, [ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (make-assembly) on project maven-first: Failed to create assembly: Error creating assembly archive jar-with-dependencies: IOException when zipping com/hp/hpl/sparta/BuildDocument.class: invalid LOC header (bad signature) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [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 read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException PinYinTest中就是一条输出语句,就输出一句话
    2019-09-26 10:45:07
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
SSM主流框架入门与综合项目实战2018版
  • 参与学习           人
  • 提交作业       205    份
  • 解答问题       4317    个

Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码