编码问题
1. JAVA编译时的编码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <project> ... <properties> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> </properties> ... </project>
<project> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.6</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> ... <project>
|
2. 复制文件时的编码问题 在pom.xml的properties节点(如果没有就创建)中新增以下属性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <project> ... <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> ... </project>
<project> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <configuration> <outputEncoding>UTF-8</outputEncoding> </configuration> </plugin> </plugins> ... <project>
|
3. 生成站点时的编码问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <project> ... <properties> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> ... </project>
<project> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.6</version> <configuration> <outputEncoding>UTF-8</outputEncoding> </configuration> </plugin> </plugins> ... <project>
|
4. 如果以上还解决不了乱码问题
设置运行时参数
IDEA在Debug Configurations窗口的 VM Options:中设置
JDK问题
自定义编码JDK版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <project> ... <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> ... </project>
<project> ... <build> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> ... </build> ... </project>
|
参考文档 http://maven.apache.org/general.html