java - spring-boot-maven-plugin:2.0.0.RELEASE:repackage 失败:无法重命名
问题描述
我使用 command: mvn package
来打包我的项目,pom.xml 如下:
<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>
但它失败了,因为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'
此异常发生在 Windows 10 上,但在 centos 7 上没问题。
谁能帮我解决这个问题
解决方案
尝试使用
mvn 清洁包
或者
mvn 干净安装
将 clean 与 package 或 install 一起使用将清除目标目录,这样同一个 jar 就不会在目标位置重叠。
package 将编译您的代码并将其打包。例如,如果你的 pom 说项目是一个 jar,它会在你打包时为你创建一个 jar,并将它放在目标目录的某个位置(默认情况下)。
install 将编译和打包,但它也会将包放在本地存储库中。这将使其他项目可以引用它并从您的本地存储库中获取它。
推荐阅读
- python - Python Instagram 机器人
- c# - C# WINFORMS 控件字体在运行时不平滑
- c - 数组类型“some_typedef_name”不可分配
- reactjs - 身份验证后的预渲染路由
- php - Docker、nginx 和 Grav 的权限问题
- c# - 使用 ctrl+tab 添加到 tabcontrol 的每隔一个 tabpage 不会触发事件
- javascript - HTML 和 Javascript 搜索结果分页 - 限制显示的结果页面数量
- c# - 如何在 Gridview 中获取第一行和最后一行?
- gitlab-ci - 当我运行 cypress 作为 npm run cypress run build 失败
- angular - “ng generate universal”和“ng add @nguniversal/express-engine”有什么区别?