为什么Maven在构建中使用历史中不存在的类和依赖项

时间:2015-01-18 18:53:42

标签: intellij-idea jboss7.x maven-3 java-ee-6

我正在使用maven 3.2.1。对于我的项目。 Maven构建工件并将类和依赖项放入不存在的类中。例如,我使用omnifaces作为pom文件中的依赖项。我在几周前从pom文件中删除了omnifaces,但是maven仍然将它构建到工件中。另一个问题是,maven构建了一个旧的和新的项目结构。我删除了一个包并将所有类放到另一个包中,但是maven仍然在新包旁边构建旧包。这会在某些点导致ClassCastException。 我想知道是否有人知道这个问题。有没有办法配置maven只使用当前的依赖项和项目结构来构建工件?

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT;     4.0.0

<parent>
    <groupId>myProject</groupId>
    <artifactId>webApplication</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<artifactId>webApplication-war</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>myProject</groupId>
        <artifactId>model-jar</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>myProject</groupId>
        <artifactId>ordering-ejb</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <scope>provided</scope>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>javax.faces-api</artifactId>
        <version>2.2</version>
    </dependency>

    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
    </dependency>

    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<name>${project.artifactId}-1.0-SNAPSHOT</name>
<!--<url>http://localhost</url> -->

<!--<build>-->
    <!--<finalName>${project.artifactId}-1.0-SNAPSHOT</finalName>-->
    <!--<pluginManagement>-->
        <!--<plugins>-->
            <!--<plugin>-->
                <!--<groupId>org.apache.maven.plugins</groupId>-->
                <!--<artifactId>maven-war-plugin</artifactId>-->
                <!--<version>2.4</version>-->
                <!--<configuration>-->
                    <!--<packagingExcludes>WEB-INF/lib/model-1.0-SNAPSHOT.jar</packagingExcludes>-->
                    <!--<webappDirectory>src/main/webapp</webappDirectory>-->
                    <!--<webXml>src/main/webapp/WEB-INF/web.xml</webXml>-->
                    <!--<outputDirectory>${env.M3_REPO}/ordentity/webApplication/1.0-SNAPSHOT</outputDirectory>-->
                <!--</configuration>-->
            <!--</plugin>-->
        <!--</plugins>-->
    <!--</pluginManagement>-->
    <!--<plugins>-->
        <!--<plugin>-->
            <!--<groupId>org.apache.maven.plugins</groupId>-->
            <!--<artifactId>maven-dependency-plugin</artifactId>-->
            <!--<version>2.8</version>-->
            <!--<executions>-->
                <!--<execution>-->
                    <!--<phase>install</phase>-->
                    <!--<goals>-->
                        <!--<goal>copy</goal>-->
                    <!--</goals>-->
                    <!--<configuration>-->
                        <!--<overWriteIfNewer>true</overWriteIfNewer>-->
                        <!--<artifactItems>-->
                            <!--<artifactItem>-->
                                <!--<groupId>${project.groupId}</groupId>-->
                                <!--<artifactId>${project.artifactId}</artifactId>-->
                                <!--<version>${project.version}</version>-->
                                <!--<type>${project.packaging}</type>-->
                            <!--</artifactItem>-->
                        <!--</artifactItems>-->
                        <!--<outputDirectory>${env.JBOSS_HOME}/standalone/deployments</outputDirectory>-->
                    <!--</configuration>-->
                <!--</execution>-->
            <!--</executions>-->
        <!--</plugin>-->
    <!--</plugins>-->
<!--</build>-->

Maven将类和目录放入该war文件中,这在项目结构中是不存在的。我有一个名为bean的软件包,但几周前删除了它。它仍然出现在战争文件中。我真的很失望......

解答:我找到了一个有用的帖子(下面的链接),评论给了我解决方案。 我在我的项目中找到了一个classes目录:

webApplication/war/src/main/webapp/WEB-INF

它包含了构建到工件中的所有旧类。因此,maven还将所有依赖项构建到工件中。删除classes目录后,所有丑陋的副作用都消失了。

Why might Maven ignore updated classes during install?

0 个答案:

没有答案