Reputation: 1
I use command: mvn package
to package my project, and the pom.xml as follows:
<build>
<defaultGoal>compile</defaultGoal>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass/>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
but it's faild because of Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.RELEASE:repackage failed: Unable to rename 'D:\Code\analysis\server\target\access_server-2.0.0.RELEASE.jar' to '
D:\Code\nalysis\server\target\access_server-2.0.0.RELEASE.jar.original'
this exception occurs on windows 10, but it's ok on centos 7.
counld any one help me solve this problem
Upvotes: 0
Views: 2847
Reputation: 1
I had this issue recently. Easy fix.
In my case, I was trying to run mvn package
and didn't realise that the application I was trying to package was already running in debug mode. Just figure out which application is using the .jar file and cut it.
Upvotes: 0
Reputation: 301
Try using
mvn clean package
or
mvn clean install
Using clean along with package or install will clear the target directory so the same jar won't overlap at the destination.
package will compile your code and also package it. For example, if your pom says the project is a jar, it will create a jar for you when you package it and put it somewhere in the target directory (by default).
install will compile and package, but it will also put the package in your local repository. This will make it so other projects can refer to it and grab it from your local repository.
Upvotes: 1