1.編譯亂碼,設(shè)置編譯的字符集編碼和環(huán)境編碼
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
設(shè)置環(huán)境變量MAVEN_OPTS=-Xms64m -Xmx128m -Dfile.encoding=UTF-8
2.運(yùn)行mvn test時(shí)亂碼(IDE上運(yùn)行TestCase時(shí)OK,但是運(yùn)行maven test亂碼,結(jié)果測(cè)試不通過(guò))修改pom.xml增加如下內(nèi)容即可
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<systemProperties>
<property>
<name>net.sourceforge.cobertura.datafile</name>
<value>target/cobertura/cobertura.ser</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
設(shè)置環(huán)境變量MAVEN_OPTS=-Xms64m -Xmx128m -Dfile.encoding=UTF-8
2.運(yùn)行mvn test時(shí)亂碼(IDE上運(yùn)行TestCase時(shí)OK,但是運(yùn)行maven test亂碼,結(jié)果測(cè)試不通過(guò))修改pom.xml增加如下內(nèi)容即可
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<systemProperties>
<property>
<name>net.sourceforge.cobertura.datafile</name>
<value>target/cobertura/cobertura.ser</value>
</property>
</systemProperties>
</configuration>
</plugin>