maven项目启动时报错,通过maven test知报错原因如下:
解决方案:在pom.xml中指定项目的编码方式为utf-8
方法一:
在pom.xml的/project/build/plugins/下的编译插件声明中加入下面的配置:<encoding>UTF-8</encoding>
即:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
方法二:在pom.xml的/project/properties/下的属性配置中加入下面的配置:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding> (这两句有一句即可)
</properties>