记一次maven打包编译文件一直不正确

maven打包发现war包解压后的class文件总是跟原Java不一样

后来发现pom中这么写到

    <plugins>
             <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerId>eclipse</compilerId>
                    <optimize>true</optimize>
<!--                     <includes> -->
<!--                         <include>src/**/*.xml</include> -->
<!--                         <include>src/**/*.java</include> -->
<!--                     </includes> -->
                    <excludes>
                        <exclude>testcase/**/*.java</exclude>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                      <groupId>org.codehaus.plexus</groupId>
                      <artifactId>plexus-compiler-eclipse</artifactId>
                      <version>2.8.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>WebRoot</warSourceDirectory>
                     <packagingExcludes>
                        WEB-INF/lib/struts-*.jar,
                        WEB-INF/lib/stax-api-*.jar,
                        WEB-INF/lib/sslext-*.jar,
                        WEB-INF/lib/xom-*.jar,
                        WEB-INF/lib/xalan-*.jar,
                        WEB-INF/lib/xml-apis-*.jar,
                        WEB-INF/lib/xmlbeans-*.jar,
                        WEB-INF/lib/xmlParserAPIs-*.jar,
                        WEB-INF/lib/kxml2-min-*.jar,
                        WEB-INF/lib/mail-*.jar,
                        WEB-INF/lib/commons-validator-*.jar,
                        WEB-INF/lib/commons-chain-*.jar,
                        WEB-INF/lib/activation-*.jar,
                        WEB-INF/lib/antlr-*.jar,
                        WEB-INF/lib/ant-launcher-*.jar,
                        WEB-INF/lib/icu4j-*.jar
                     </packagingExcludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <!-- <plugin> <groupId>org.zeroturnaround</groupId> <artifactId>jrebel-maven-plugin</artifactId> 
                <version>1.1.6</version> <executions> <execution> <id>generate-rebel-xml</id> 
                <phase>process-resources</phase> <goals> <goal>generate</goal> </goals> </execution> 
                </executions> </plugin> -->
        </plugins>

而我一直没有发现,自己的WEB-INFO  目录下同样存在一个class文件,由于项目默认的打包路径也是WEB-INFO  故,pom中那样写法  会导致原WEN-INFO 小的文件  一直会覆盖新编译的文件 

 

posted @ 2019-06-25 18:14  valar-dohaeris  阅读(1280)  评论(0编辑  收藏  举报