本文介绍了使用maven构建时,jar文件被破坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构建war文件时,我正在将一组罐子从一个位置复制到战争中的文件夹中。虽然文件确实被复制了,但是我认为它们被破坏了,因为在战争之外拍摄的jar的相同类文件打开了调试器,而在从war文件中取出后它没有打开。

while building a war file i am copying a set of jars from a location to a folder inside the war. While the files do get copied , however i think they get corrupted because the same class files of the jar when taken outside the war opens with a debugger while it does not open after taking from war file .

这是我的战争pom.xml的一部分,我在那里复制罐子

This is a part of my war pom.xml where i copy the jars

<execution>
    <id>copy-jars</id>
    <phase>process-resources</phase>
    <goals>
        <goal>copy-resources</goal>
    </goals>
    <configuration>
        <outputDirectory>${basedir}/target/${project.artifactId}-${buildNumber}/somefolder</outputDirectory>
         <resources>
            <resource>
                <directory>SomeSourceDirectory</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
        </resources>
    </configuration>
</execution>

SomeSourceDirectory 有一些罐子和一些其他文件
结果是:
myWar / somefolder / a.jar但是当我在调试器中打开这个jar里面的类时...在WinZip中得到错误

SomeSourceDirectory has some jars and some other filesThe result is:myWar/somefolder/a.jar but when i open the classes inside this jar in a debugger..i get error in WinZip that

Invalid compressed data to extract.
Severe Error:  Compressed data is invalid

但是我可以查看相同的类文件在原始文件夹中查看,即在战争之外。
复制罐子时有错吗?
谢谢。

However the same class file can be viewed when i view it in original folder i.e outside the war.So is there a mistake while copying the jars?Thanks.

推荐答案

删除< filtering> true< / filtering> ,它会破坏jar文件。

Remove <filtering>true</filtering>, it corrupts the jar files.

这篇关于使用maven构建时,jar文件被破坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:14