skip to Main Content

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:Codeanalysisservertargetaccess_server-2.0.0.RELEASE.jar' to '
D:Codenalysisservertargetaccess_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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. I my case cmd was open with target folder

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search