maven編譯帶中文的工程時出現syntax error的問題,mavensyntax
在編譯帶中文的maven工程時,儘管pom檔案中設定了<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>,但仍然會報錯,如下資訊:
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.7.2:scr (generate-scr-scrdescriptor) on project toolkit.monitor.manager: Execution generate-scr-scrdescriptor of goal org.apache.felix:maven-scr-plugin:1.7.2:scr failed: syntax error @[193,1] in file:/E:/wso2-svn/toolkit.monitor.manager/src/main/java/com/shuhao/toolkit/monitor/manager/WarnHandler.java -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
通過clean install -X命令執行編譯查看詳細報錯資訊,發現其中有一行這樣的錯誤:
Caused by: com.thoughtworks.qdox.parser.ParseException:syntax error@[193,1] in file:/E:/wso2-svn/toolkit.monitor.manager/src/main/java/com/shuhao/toolkit/monitor/manager/WarnHandler.java
後面我終於發現了是因為檔案中存在某些中文字元導致編譯打包出錯,只要將這些中文換成其他的中文即可通過編譯。不過還不清楚為什麼有的中文編譯不過去,知道的大神指點下,謝謝
用maven編譯項目時出現如下問題
程式亂了
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
maven工程編譯並產生可執行JAR包命令
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.abc.ABCTest</mainClass> -->入口類名
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory> -->拷貝所以依賴存放位置
</configuration>
</execution>
</executions>
</plugin>
</plugins>
然後再用mvn clean install 裝配一下,打出的jar包就可以運行...餘下全文>>