The encoding format that is involved in Maven

Source: Internet
Author: User

Personally, when executing an order, mvn clean install often encounters

Illegal characters: \65279 illegal expressions start and so on some strange mistakes.

Personally, consider the encoding format of your MAVEN configuration first.

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

To confirm that the above <project.build.sourceEncoding> content is already in the Pom file, add the following (if the relevant content of Maven-compiler-plugin is included, You only need to add a portion of the red font to the appropriate location):

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

Attention:

1. Also specify the <project.build.sourceEncoding> properties and <encoding> method can be applied to Maven2 and Maven3.

2, in the Maven3 can only add <project.build.sourceEncoding> properties without specifying <ENCODING>, that is, can solve the compilation problem. If you specify only <encoding> compile without errors, the following warning appears. It is recommended to either specify or only specify the former. The warning message is as follows:
[WARNING] Using platform Encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

3. In Maven2, if only the <project.build.sourceEncoding> attribute is specified, compile error, if only specify <encoding> compile no error, but there will be a warning similar to the 2nd, It is recommended that both be specified to avoid any impact on the operation. Execute MVN, generate a good jar package and reference this jar and its source jar in other projects, if it is garbled, it may be the configuration problem of Eclipse, confirm windows->preferences->general->workspace- >text file encoding is set to UTF-8 confirm Windows->preferences->general->content types-> Right context Types tree, open Text, Select Java Source File, enter UTF-8 in the default encoding input box below, point to update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.