eclipse下maven console汉字乱码

运行selenium case时,testng正常,用maven调用testng时,eclipse console汉字乱码,在pom.xml中设置下编码即可。

1.编译乱码,设置编译的字符集编码和环境编码

<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>

设置环境变量MAVEN_OPTS=-Xms64m -Xmx128m -Dfile.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>

参考:http://www.blogjava.net/wangzhouyu/archive/2011/06/30/353403.html

版权声明

本站文章、图片、视频等(除转载外),均采用知识共享署名 4.0 国际许可协议(CC BY-NC-SA 4.0),转载请注明出处、非商业性使用、并且以相同协议共享。

© 空空博客,本文链接:https://www.yeetrack.com/?p=36