做毕设的时候用maven compile项目的时候,有时会出现非常奇怪的错误,比如xxxx位置缺少; xxx位置注释不正确。。。这种情况下代码是没有语法问题的,但是maven就是编译不过,后来查了好久才找到原来maven默认是gbk字符集的,我的项目是utf8,要配置编译的选项。。。
下面是具体的配置代码
注意最后的一个plugin就是配置字符集的
<build> <finalName>WebDisk</finalName> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.10</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <stopKey>foo</stopKey> <stopPort>9999</stopPort> </configuration> <executions> <execution> <id>start-jetty</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> </goals> <configuration> <scanIntervalSeconds>0</scanIntervalSeconds> <daemon>true</daemon> </configuration> </execution> <execution> <id>stop-jetty</id> <phase>post-integration-test</phase> <goals> <goal>stop</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>