繁体   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