您好,登錄后才能下訂單哦!
小編給大家分享一下maven在eclipse中的問題有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
Unrecognised tag
問題
由于我使用本地代理倉庫,所以settings.xml設置如下:
<profiles> <profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>Nexus</name> <url>http://localhost:8081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>Nexus</name> <url>http://localhost:8081/nexus/content/groups/public</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </pluginRepository> </pluginRepositories> </profile> <!--激活配置--> <activeProfiles> <activeProfile>nexus</activeProfile> </activeProfiles> </profiles>
但在Maven編譯時報了如下異常:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Unrecognised tag: 'activeProfiles' (position: START_TAG seen ...\n\t... @269:18) @ C:\Documents and Settings\Administrator.ZQFGROUP.000\.m2\settings.xml, line 269, column 18
[WARNING]
解決
這是因為錯把activeProfiles配置到了profiles節點里了,應該把activeProfiles移到profiles之外,更多settings.xml配置信息請參考這里。
No goals
問題
Eclipse安裝了Maven插件后,在項目的pom.xml上右鍵能看到如下:
而我自作聰明地認為:Maven build 與 mvn compile 是等價的,于是我再點擊"Maven build..."之后,“Goals”是空的,如:
于是就報了這樣的錯誤:
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format:or:[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
解決
解決方法至少有兩種:
再點擊"Maven build..."之后,輸入你要執行的“Goals”,如compile,clean,test等等;
在pom.xml中配置默認的Goal,如:
<build> <defaultGoal>clean</defaultGoal> </build>
作為project的子節點。
not a JRE
問題
在使用pom.xml配置默認Goal的時,如果默認的Goal為clean就沒問題,但如果是如:
就會報錯誤:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Demo: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
經過幾番嘗試,才發現并不是多個Goal的問題,而是compile Goal的問題。但使用命令的"mvn compile"又是OK的。
幾經折騰才發現錯誤里說的很清楚:Please ensure you are using JDK 1.4 or above and not a JRE",它需要的是JDK而不是JRE。我給的項目中使用的是公共JRE:
解決
修改Eclipse的配置,使用JDK:Eclipse->Window->Preferences->Java->Installed JREs
system propery is not set
錯誤:-Dmaven.multiModuleProjectDirectory system propery is not set.
新建一個環境變量M2_HOME指向你的maven安裝目錄
M2_HOME=D:\study\apache-maven-3.3.3
然后在Window->Preference->Java->Installed JREs->Edit
在Default VM arguments中設置
-Dmaven.multiModuleProjectDirectory=$M2_HOME
5. Launching New_configuration
項目上右擊->Run/Debug Settings->刪除 new_Configuration.
以上是“maven在eclipse中的問題有哪些”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。