1. maven compile亂碼編譯不過去,檢查已是utf-8無bom編碼
看上去不是源代碼的問題,是編譯工具maven出了異常,換一個版本的jdk試一下,我以前遇到過用ant編譯用jdk1.6出現異常,用jdk1.7則正常;另外你用支持UTF8的軟體如記事本或網頁瀏覽器(編碼要選擇utf8)等打開你的RegexUtil.java文件看一下21行是不是有亂碼
2. maven總是配置不成功,是什麼原因
遇到的問題和解決
錯誤1 :
[ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve
dependencies for project biz_zhuhai:biz_zhuhai:jar:0.0.1-SNAPSHOT:
Failed to collect dependencies for [com.maywide.ibh:lib345:pom:1.0
(compile)]: Failed to read artifact descriptor for
com.maywide.ibh:lib345:pom:1.0: Could not transfer artifact
com.maywide.ibh:lib345:pom:1.0 from/to releases
(http://localhost:9888/nexus-2.0.3/content/repositories/releases):
Connection to http://localhost:9888 refused: Connection refused: connect
-> [Help 1]
解決:這是配置的url有錯誤或者是私服沒有配好,導致構件下載時出錯。如果沒有jar包需要在私服里下載,可以不配置私服的,可以把setting.xml的profiles里的東西全部刪除的。
錯誤2:[ERROR]
Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test)
on project web_nanchang: There are test failures.
[ERROR]
[ERROR] Please refer to E:\maven\web_nanchang\target\surefire-reports for the indivial test results.
解決:這是因為測試代碼時遇到錯誤,會停止編譯。只需要在pom.xml的<project>里添加以下配置,使得測試出錯不影響項目的編譯。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
錯誤3:
[ERROR]
Failed to execute goal
org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on
project web_nanchang: Error assembling WAR: webxml attribute is required
(or pre-existing WEB-INF/web.xml if executing in update mode) ->
[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:
解決:maven的web項目默認的webroot是在src\main\webapp。如果在此目錄下找不到web.xml就拋出以上的異常。解決方法在pom.xml加入以下的配置。紅色背景字體改成你網站的根目錄。
<build>
<finalName>simple-webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>WebContent</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
錯誤4:
嚴重: The web application [/web_nanchang] registered the JBDC driver
[org.hsqldb.jdbc.JDBCDriver] but failed to unregister it when the web
application was stopped. To prevent a memory leak, the JDBC Driver has
been forcibly unregistered.
2012-4-27 10:36:49 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
嚴重: The web
application [/web_nanchang] registered the JBDC driver
[com.mysql.jdbc.Driver] but failed to unregister it when the web
application was stopped. To prevent a memory leak, the JDBC Driver has
been forcibly unregistered.
不知道怎樣解決,導致運行不了。
錯誤5:
把java complier改成1.6或者disabled dependency manangent後在enable消失了。
3. java eclipse導入Maven,ava環境一切已設置,發現問題maven不編譯。怎麼處理
先讓這個maven工程轉換為非maven工程。方法:右鍵工程--maven--Disable maven nature。在當前目錄下執行命令(就是有pom.xml文件的那個目錄) —— mvn eclipse:clean。最後,重新轉換該工程為maven工程。右鍵工程--- 'Configure'--- 'Convert to Maven Project'
4. 大佬求助Maven編譯java文件失敗是怎麼回事
問題描述:
在eclipse中build一個普通maven項目,報錯,提示信息是缺少maven插件(插件名稱忘了)。
原因:
可能是由於使用了eclipse自帶的jre導致的,這個jre里沒有tools.jar,而jdk的lib目錄下有(個人理解)。
解決辦法:
1、檢查eclipse的配置,確保使用的不是eclipse自帶的版本。
步驟:在eclipse中打開Window->Preferences->Java->Installed JREs->Add,添加自己下載並配置好的jdk(別忘了配置環境變數),我用的是jdk1.6.0_4.3。
2、然後再次編譯maven項目,仍然報錯,但提示信息改變了,提示的是C:\Users\Administrator.EED4VRFALFPIIBP\.m2\repository\commons-logging\commons-logging下的jar包解析失敗; 3、解決方案:刪除repository文件夾,確保網路暢通,重啟eclipse,執行Maven->Project Update,問題解決。
注意:如果你的eclipse中配置了tomcat,那麼你也需要重新選擇tomcat的jdk版本,確保與前面的一致。 步驟:在eclipse中打開Window->Preferences->Server->Runtime Environment->選中你的tomcat server->Edit,在JRE這項里選擇你的jdk,完成。
5. maven 項目,保存後不自動編譯,每次都要clean ,install後,target下面的class文件才會變化
多半是Maven的依賴包損壞,所以停止automatical compile。可以用mvn test一下測試一下編譯,看一下有哪些jar包有錯誤,到repository裡面刪了讓maven重新下載一遍一般就好了。
詳情請參考http://www.cnblogs.com/hejing195/p/7413837.html
6. java eclipse導入Maven工程 java環境一切已設置好,發現問題maven不編譯而且彈出框內容如下:
1,先讓這個maven工程轉換為非maven工程。方法:右鍵工程--maven--Disable maven nature
2,在當前目錄下執行命令(就是有pom.xml文件的那個目錄) —— mvn eclipse:clean
3,重新轉換該工程為maven工程。右鍵工程--- 'Configure'--- 'Convert to Maven Project'
試試
7. 為什麼mvn編譯時,不把.json文件也編譯
你已經用gcc編譯出目標文件了,用ar工具打包成.a文件就行了啊,示例: 如上圖,假設我有test1.c,test2.c兩個源文件,先使用gcc -c *.c將源文件編譯成目標文件,可以看到,生成了test1.o,test2.o兩個目標文件,然後,使用ar命令:ar crv libtes
8. maven pom文件編譯報錯
cmd可以運行mvn -v只是表示你的電腦安裝好了maven。你的報錯信息提示當前項目不是一個maven項目,因為找不到pom.xml文件。建議你看看 《maven實戰》這本書。
9. Maven如何不編譯而直接啟動Jetty中上次編譯好的項目
使用maven jetty 插件,並不會打成war包然後部署到jetty。。。
它是以嵌入式方式運行,jetty 直接監控某個運行目錄,當文件發生變化時,如果新編譯了修改的文件,它會作出相應的載入,這非常適合增量開發。