简体   繁体   中英

spring-boot-maven-plugin:2.0.0.RELEASE:repackage failed: Unable to rename

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

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.

I my case cmd was open with target folder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM