公司的WEB项目是GBK编码的,组里基本上都是用eclipse的,IDEA中碰到的很多问题都要重新去解决。
1. 输出乱码问题
先倒不提代码中输出的中文了,编译、mvn build以及tomcat日志都有乱码。网上搜了一下,比较靠谱的是:
http://www.kafeitu.me/tools/2013/03/26/intellij-deal-chinese-disorderly-code.html
这里提到的解决方案。这个方案基本上能够解决IDEA的乱码问题,除了在调用autoconfig的时候还是会输出乱码,这时还是需要在pom文件中指定一下maven-autoconfig-plugin的编码。默认是没有指定的,这样它会用系统默认的,如果LC_ALL环境变量为空,那就会使用MacRoman,显然这对中文输出是有问题的。修改pom后如下:
<plugin>
<groupId>com.alibaba.citrus.tool</groupId>
<artifactId>maven-autoconfig-plugin</artifactId>
<version>1.0.9</version>
<configuration>
<exploding>true</exploding>
<explodedDirectory>
${warExplodedDirectory}
</explodedDirectory>
<charset>GBK</charset>
</configuration>
<executions>
<execution>
<pha