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:
1 <!--Specify the character encoding to use when compiling the source code, the GBK encoding that is used by default when Maven compiles, and the Project.build.sourceEncoding property to set the character encoding to tell Maven that the project uses UTF-8 to compile-- >2 <properties>3 <project.build.sourceencoding>utf-8</project.build.sourceencoding >4 </properties>
Or, add the following configuration to the compiler plug-in declaration under Pom.xml/project/build/plugins/:
1 <encoding>utf8</encoding>
That
1 <plugin> 2 <artifactId>maven-compiler-plugin</artifactId> 3 <configuration> 4 <source>1.6</source> 5 <target>1.6</target> 6 <!--indicate the character encoding to use when compiling the source code, 7 When Maven compiles the GBK encoding by default, 8 sets the character encoding via the encoding property, 9 tells Maven this project uses UTF-8 to compile-->10 <encoding> utf8</encoding> </configuration>12 </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.
Using a maven-compiled project encounters a "GBK character for MAVEN encoding" workaround