报错filtering ..\main\resources\lib\\xx**.jar to \target\classes\lib\\**xx.jar failed with Malformed..

报错信息:filtering … \src\main\resources\lib\xx**.jar to \target\classes\lib\**xx.jar failed with MalformedInputException: Input length = 1 -> [Help 1]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources (default-resources) on project 项目名: filtering 项目路径\src\main\resources\lib\bcpkix-jdk15on-1.70.jar to 项目路径\target\classes\lib\bcpkix-jdk15on-1.70.jar failed with MalformedInputException: Input length = 1 -> [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 
[ERROR]  
[ERROR] After correcting the problems, you can resume the build with the command [ERROR]   mvn <args> -rf :pig-upms-biz

该问题在项目使用Maven clean install的时候出现的,一开始想的是,是否与这个jar包 (bcpkix-jdk15on-1.70.jar) 有关系?但是在pom文件中把对应的依赖注释掉后,并没有解决问题。

看一下完整的报错解析,关键在于两个路径。发现是打包的时候,有一步操作需要把\src\main\resources\lib\下的jar包转移到target\classes\lib\之下,但是Input length说明导入的jar包数目不对。

原因分析:

因为项目需要用到一些外部jar包,一开始是使用如以下这种相对路径的方式引入,并把jar包放置在${project.basedir}/src/main/resources/lib/之下。

<dependency>
    <groupId>org.zz</groupId>
    <artifactId>gmhelper</artifactId>
    <version>1.0.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/src/main/resources/lib/gmhelper-1.0.0.jar</systemPath>
</dependency>

而项目的有一个打包插件,也就是报错的路径来源,就是转移jar包。

<plugins>
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-war-plugin</artifactId>
       <version>3.3.2</version>
       <configuration>
          <webResources>
             <resource>
                <directory>src/main/resources/lib</directory>
                <targetPath>WEB-INF/lib/</targetPath>
                <includes>
                   <include>**/*.jar</include>
                </includes>
                <excludes>
                   <exclude>**/commons-io-2.5.jar</exclude>
                </excludes>
             </resource>
          </webResources>
       </configuration>
    </plugin>
</plugins>

但是,后续又使用了如以下指令。这个指令会将Jar解析并放入本地仓库,这样的话使用插件再将jar包直接放到打包好的war包的WEB-INF/lib路径下,显示是不合适的。

mvn install:install-file -Dfile=相对路径/gmhelper-1.0.0.jar -DgroupId=org.zz 
-DartifactId=gmhelper -Dversion=1.0.0 -Dpackaging=jar -Dmaven.repo.local={repository路径}

于是,如何解决?

插件可以不需要改动它,直接将${project.basedir}/src/main/resources/lib/下相关的jar包备份起来,并在该路径下删除掉,重新执行服务,若服务能够正常跑不报错,就执行maven clean install就可以正常打出包了。

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值