原因:
在代码中包含了字体库文件 如图:

当含有非java文件打包时会,打包失败 报错
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.2.RELEASE:repackage (default) on project wms-weighing: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.2.RELEASE:repackage failed: Unable to rename 'D:\ideaWorkOne\wms-weighing\target\wms-weighing-0.0.1-SNAPSHOT.war' to 'D:\ideaWorkOne\wms-weighing\target\wms-weighing-0.0.1-SNAPSHOT.war.original' -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
尝试:
删除 SIMKAI.TTF该文件后打包 ,成功了但是 war包中没有该字体库调用时 会导致中文无法加载,每次手动将字体库加入war中比较麻烦
解决办法:
需要在pom.xml配置文件中build节点的resources下增加一个resource,指定directory为src/main/java目录,然后配置include包含**/*.TTF即可,代码如下:
<build>
<resources>
<resource>
<directory>{project.basedir}/src/main/java/com/weighbridge/util</directory>
<includes>
<include> **/*.TTF</include>
</includes>
</resource>
</resources>
<defaultGoal>compile</defaultGoal>
</build>/src/main/java/com/weighbridge/util 为文件存放目录,可参考图一。
idea 还是同样的代码,打war包还是没有字体库
pom文件改成如下代码:
<build>
<!-- <resources>
<resource>
<directory>{project.basedir}/src/main/java/com/weighbridge/util</directory>
<targetPath>{project.basedir}/WEB-INF/classes/com/weighbridge/util</targetPath>
<includes>
<include> **/*.TTF</include>
</includes>
</resource>
</resources>-->
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>src/main/java/com/weighbridge/util</directory>
<targetPath>WEB-INF/classes/com/weighbridge/util</targetPath>
<includes>
<include> **/*.TTF</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
这样就会包含非java 文件了
版权声明:本文为qq_27292113原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。