maven編譯帶中文的工程時出現syntax error的問題,mavensyntax

來源:互聯網
上載者:User

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包就可以運行...餘下全文>>
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.