在用IDEA maven開發時,控制檯輸出、zip打包、class編碼等現現各類亂碼,可經過在pom.xml進行以下配置來解決亂碼: java
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> <configuration> <target>1.8</target> <source>1.8</source> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>${maven-resources-plugin.version}</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven-surefire-plugin.version}</version> <configuration> <argLine>-Dfile.encoding=UTF-8</argLine> </configuration> </plugin> </plugins> </build>
在 IDEA中也須要把文件自身的編碼設置一下: apache