一、mvn编码【平台编码】:
mvn -vesion
默认是GBK
如何修改?
在系统变量中加入:
设置windows环境变量:
Key: MAVEN_OPTS
Value: -Xms256m -Xmx512m -Dfile.encoding=UTF-8
二、修改pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
或者
<build> <plugins> <!-- 指定jdk,防止update project --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <!-- 项目编码--> <encoding>UTF-8</encoding> </configuration> </plugin> </build>
//源码,输出,编译都是GBK
<properties>
<project.build.sourceEncoding>GBK</project.build.sourceEncoding> <project.reporting.outputEncoding>GBK</project.reporting.outputEncoding> <maven.compiler.encoding>GBK</maven.compiler.encoding>
</properties>
注意:源文件也需要时UTF-8编码 --------------------- 作者:starcraft501 来源:CSDN 原文:https://blog.csdn.net/starcraft501/article/details/82718285 版权声明:本文为博主原创文章,转载请附上博文链接! |