maven构建依赖jar文件不反映代码中的更改

时间:2017-10-06 10:37:20

标签: java maven

我正在尝试使用目标mvn包构建一个maven项目。当我构建项目时,两个jar文件生成一个demo-lwm2m-client-1.0-jar-with-dependencies.jar和另一个demo-lwm2m-client -1.0.jar。现在如果我对放在src / main / resources中的文件进行一些更改并再次构建项目,我发现demo-lwm2m-client-1.0-jar-with-dependencies.jar没有反映出我在代码中做了更改,而demo-lwm2m-client-1.0.jar反映了更改。如何在依赖jar中反映我的代码更改.Below是我的pom.xml的代码。    http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

<groupId>com.demo.lwm2m.client</groupId>
<artifactId>demo-lwm2m-client</artifactId>
<packaging>jar</packaging>
<version>1.0</version>

<name>DemoLwm2mClient</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.eclipse.leshan</groupId>
        <artifactId>leshan-client-cf</artifactId>
        <version>1.0.0-M1</version>
    </dependency>


    <dependency>
        <groupId>com.appiot.examples</groupId>
        <artifactId>simulatedplatform</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>       
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
</dependencies>
<repositories>

    <repository>
        <id>eclipse</id>
        <url>https://repo.eclipse.org/content/repositories/leshan-snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>       
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.demo.lwm2m.MainClass</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>

1 个答案:

答案 0 :(得分:1)

使用mvn clean install。这将重建所有内容,并包含所有更改。