簡體   English   中英

如何在Eclipse中創建Maven項目

[英]How To Create Maven Project in eclipse

我是eclipse的新手。從今天開始,我開始工作eclipse。 我的要求是在eclipse.net中生成一個簡單的maven項目,因此我將我的maven放在我的C驅動器中並運行mvn -version.it顯示版本,並且我假設已安裝maven。

現在我試圖在我的cmd中執行以下命令,但它總是顯示錯誤。

mvn archetype:generate -DgroupId=com.selva -DartifactId=SampleApplication -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

錯誤是

C:\Users\selva>mvn archetype:generate -DgroupId=com.selva
rtifactId=SampleApplication -DarchetypeArtifactId=maven-archetype-qui
tart -DinteractiveMode=false
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-cle
plugin:2.5 or one of its dependencies could not be resolved: Failed t
ead artifact descriptor for org.apache.maven.plugins:maven-clean-plug
jar:2.5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-install-plugin/2.4/maven-install-plugin-2.4.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-i
all-plugin:2.4 or one of its dependencies could not be resolved: Fail
to read artifact descriptor for org.apache.maven.plugins:maven-instal
lugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-de
y-plugin:2.7 or one of its dependencies could not be resolved: Failed
 read artifact descriptor for org.apache.maven.plugins:maven-deploy-p
in:jar:2.7
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site
ugin:3.3 or one of its dependencies could not be resolved: Failed to
d artifact descriptor for org.apache.maven.plugins:maven-site-plugin:
:3.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-an
n-plugin:1.3 or one of its dependencies could not be resolved: Failed
 read artifact descriptor for org.apache.maven.plugins:maven-antrun-p
in:jar:1.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins
ven-assembly-plugin:2.2-beta-5 or one of its dependencies could not b
esolved: Failed to read artifact descriptor for org.apache.maven.plug
:maven-assembly-plugin:jar:2.2-beta-5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-dependency-plugin:2.8: Plugin org.apache.maven.plugins:mave
ependency-plugin:2.8 or one of its dependencies could not be resolved
ailed to read artifact descriptor for org.apache.maven.plugins:maven-
endency-plugin:jar:2.8
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.p
ins:maven-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven
lease-plugin:2.3.2 or one of its dependencies could not be resolved:
led to read artifact descriptor for org.apache.maven.plugins:maven-re
se-plugin:jar:2.3.2
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/pl
ns/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/m
n-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-
adata.xml from/to central (https://repo.maven.apache.org/maven2): Con
t to repo.maven.apache.org:443 [repo.maven.apache.org/23.235.47.215]
led: Connection timed out: connect
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadat
ml from/to central (https://repo.maven.apache.org/maven2): Connect to
po.maven.apache.org:443 [repo.maven.apache.org/23.235.47.215] failed:
nnection timed out: connect
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata
l from https://repo.maven.apache.org/maven2 was cached in the local r
sitory, resolution will not be reattempted until the update interval
central has elapsed or updates are forced. Original error: Could not
nsfer metadata org.apache.maven.plugins/maven-metadata.xml from/to ce
al (https://repo.maven.apache.org/maven2): Connect to repo.maven.apac
org:443 [repo.maven.apache.org/23.235.47.215] failed: Connection time
ut: connect
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml fr
https://repo.maven.apache.org/maven2 was cached in the local reposito
 resolution will not be reattempted until the update interval of cent
 has elapsed or updates are forced. Original error: Could not transfe
etadata org.codehaus.mojo/maven-metadata.xml from/to central (https:/
po.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [re
maven.apache.org/23.235.47.215] failed: Connection timed out: connect
[INFO] --------------------------------------------------------------
-------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------------------------
-------
[INFO] Total time: 04:07 min
[INFO] Finished at: 2014-09-16T16:44:58+05:30
[INFO] Final Memory: 8M/99M
[INFO] --------------------------------------------------------------
-------
[ERROR] No plugin found for prefix 'archetype' in the current project
d in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
ilable from the repositories [local (C:\Users\uniphore\.m2\repository
central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with
 -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,
ease read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoP
inFoundForPrefixException
C:\Users\Selva>

我想在Eclipse中創建一個簡單的Maven項目。 任何幫助將不勝感激!

嘗試執行此步驟。

1)在Eclipse IDE中,導航到“文件”>“新建”>“其他...”,以調出項目創建向導。

2)滾動到Maven文件夾,打開它,然后選擇Maven Project。 然后選擇下一步。

3)您可以選擇創建一個簡單的項目或放棄此選項。 就本教程而言,我們將選擇簡單的項目。 這將創建一個基本的,啟用Maven的Java項目。 如果需要更高級的設置,請取消選中此設置,您將能夠使用更高級的Maven項目設置功能。 保留其他選項不變,然后單擊“下一步”。

4)現在,您將需要輸入有關正在創建的Maven項目的信息。 您可以訪問Maven文檔以更深入地了解Maven坐標( http://maven.apache.org/pom.html#Maven_Coordinates )。 通常,組ID應與您的組織名稱相對應,工件ID應與項目名稱相對應。 版本以及包裝和其他字段均由您決定。 如果這是一個沒有父項依賴項的獨立項目,則可以保留“父項”部分。 填寫適當的信息,然后單擊完成。

5)您現在將注意到您的項目已創建。 您將把Java代碼放在/ src / main / java中,將資源放在/ src / main / resources中,並將測試代碼和資源分別放在/ src / test / java和/ src / test / resources中。

6)打開pom.xml文件以查看Maven設置的結構。 在此文件中,您可以看到在步驟4中輸入的信息。您還可以使用窗口底部的選項卡進行更改,以查看其中的pom文件的依賴關系,依賴關系層次結構,有效POM和原始xml代碼。 pom.xml選項卡。

現在將使用Eclipse創建帶有Maven的Java項目。

如果您在Eclipse中沒有Maven,請安裝m2e。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM