Change the item directly to UTF-8 code, invalid!
To modify the Pom.xml file, tell Maven that the project uses UTF-8 to compile.
First, the problem description
When compiling project source code using MAVEN today in MyEclipse, the result is the following error
Best of all, the Java source code is displayed in MyEclipse without any errors, but the "Maven install" command compiles the project with the above error, resulting in project compilation failure. This problem is the first time, fortunately here http://capslk.iteye.com/blog/1419958 see the solution to the problem.
Ii. Solutions
The idea of solving this problem: to declare the correct character set encoding in MAVEN's compilation plugin-the character set encoding used by the compilation is consistent with the character set encoding used by the code file!!
After installing the system, the general Chinese system default character set is GBK. The software we install generally inherits the default character set that is used by the operating system. So when the Chinese XP or Win7 system development, when using MAVEN (MVN compile) to compile the project, there will be "encoding GBK non-mapped characters": This is due to the use of code UTF-8, and Maven compiled with the use of GBK for the sake of. By modifying the project's Pom file, you can tell Maven that the project compiles using UTF-8 encoding. Add the following configuration to the project's Pom.xml file:
<!--Specifies the character encoding to use when compiling the source code, the GBK encoding that is used by default when Maven compiles, and the character encoding via the Project.build.sourceEncoding property to tell Maven that the project uses UTF-8 to compile - <Properties> <!--encoding when copying files - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <!--compile-time encoding - <maven.compiler.encoding>UTF-8</maven.compiler.encoding> </Properties>
Or, add the following configuration to the compiler plug-in declaration under Pom.xml/project/build/plugins/:
<encoding>utf8</encoding>
<plugin> <Artifactid>Maven-compiler-plugin</Artifactid> <Configuration> <Source>1.6</Source> <Target>1.6</Target> <!--Specifies the character encoding to use when compiling the source code, the GBK encoding that is used by default when Maven compiles, and the character encoding via the encoding property to tell Maven that the project uses UTF-8 to compile-
<!--Specify the encoding format, otherwise there will be an inexplicable error running the MVN compile command under DOS because the system uses GBK encoding by default -- <encoding>Utf8</encoding> </Configuration></plugin><plugin> <groupId>Org.apache.maven.plugins</groupId> <Artifactid>Maven-resources-plugin</Artifactid> <version>2.6</version> <Configuration> <encoding>UTF-8</encoding><!--Specifies the encoding format, otherwise the system defaults to use GBK encoding when file resource copy occurs when the MVN command is run under DOS - </Configuration> </plugin>
Both of these solutions solve the above problems and can be set according to personal habits, as shown in the configuration <project.build.sourceEncoding> properties to indicate the character encoding used by the compilation.
Today by this problem is long enough, fortunately found a solution in time, here to record the solution.
This article turns from: Oo Homeward Bound oo
Maven Exception Resolution: encoding GBK non-mapped characters