Maven在/ WEB-INF / lib文件夹中构建损坏的jar文件

时间:2015-01-07 11:57:07

标签: java google-app-engine maven jar

每次我构建我的maven项目并运行应用程序时,都会说

[INFO] 
[INFO] Jan 07, 2015 5:23:37 PM com.google.apphosting.utils.jetty.JettyLogger warn
[INFO] WARNING: Failed to read file: C:\app\target\app-1.0\WEB-INF\lib\datanucleus-jpa-1.1.5.jar
[INFO] java.util.zip.ZipException: error in opening zip file
[INFO]  at java.util.zip.ZipFile.open(Native Method)
[INFO]  at java.util.zip.ZipFile.<init>(ZipFile.java:215)
[INFO]  at java.util.zip.ZipFile.<init>(ZipFile.java:145)
[INFO]  at java.util.jar.JarFile.<init>(JarFile.java:153)
[INFO]  at java.util.jar.JarFile.<init>(JarFile.java:117)
[INFO]  at org.mortbay.jetty.webapp.TagLibConfiguration.configureWebApp(TagLibConfiguration.java:174)
[INFO]  at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1247)
[INFO]  at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
[INFO]  at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
[INFO]  at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO]  at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO]  at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO]  at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO]  at org.mortbay.jetty.Server.doStart(Server.java:224)
[INFO]  at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO]  at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:255)
[INFO]  at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:288)
[INFO]  at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
[INFO]  at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:87)
[INFO]  at com.google.appengine.tools.development.Modules.startup(Modules.java:105)
[INFO]  at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:258)
[INFO]  at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
[INFO]  at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:213)
[INFO]  at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:211)
[INFO]  at java.security.AccessController.doPrivileged(Native Method)
[INFO]  at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
[INFO]  at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
[INFO]  at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
[INFO]  at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:219)
[INFO]  at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:210)

我在/ WEB-INF / lib下添加的所有罐子

这似乎不会发生在战争中通过maven依赖添加的其他罐子。

这是我的pom.xml

<build>
    <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>3.1</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archiveClasses>true</archiveClasses>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.target.version}</version>
            <configuration>
                <enableJarClasses>false</enableJarClasses>
                <address>0.0.0.0</address>
                <jvmFlags>
                    <jvmFlag>-Xdebug</jvmFlag>
                    <jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
                    <jvmFlag>-Ddatastore.backing_store=${project.basedir}\local_db.bin</jvmFlag>
                </jvmFlags>
            </configuration>
        </plugin>
    </plugins>
</build>

再次下载罐子对我没有帮助。我做了几次。请帮助我解决这个问题。

2 个答案:

答案 0 :(得分:4)

您正在过滤WEB-INF下的所有文件。这包括你的jar文件。

仅过滤那些实际需要它的文件。

答案 1 :(得分:1)

除ThorbjørnRavnAndersen外,您还可以指定排除jar文件:

<webResources>
    <resource>
        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
        <filtering>true</filtering>
        <exclude>**/*.jar</exclude>
        <targetPath>WEB-INF</targetPath>
    </resource>
</webResources>