mac mvn install 中文乱码解决方法

来源:互联网 发布:java 下载https图片 编辑:程序博客网 时间:2024/05/22 10:53
1.编译乱码,设置编译的字符集编码和环境编码 
<plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>2.3.2</version> 
        <configuration> 
                <source>1.6</source> 
                <target>1.6</target> 
                <encoding>UTF-8</encoding>
 
        </configuration> 
</plugin> 

设置环境变量export MAVEN_OPTS="-Xms128m -Xmx512m -Dfile.encoding=UTF-8" 

注意""号不能缺少,否则报错。mvn -version查看,可看到encoding :utf-8 


2.运行mvn test时乱码(IDE上运行TestCase时OK,但是运行maven 
test乱码,结果测试不通过)修改pom.xml增加如下内容即可 
<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> 
0 0