Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在eclipse中创建Maven项目_Java_Eclipse_Maven_Build - Fatal编程技术网

Java 如何在eclipse中创建Maven项目

Java 如何在eclipse中创建Maven项目,java,eclipse,maven,build,Java,Eclipse,Maven,Build,我是eclipse的新手。从今天开始我就开始使用eclipse。 我的需求是在eclipse中生成一个简单的maven项目。因此,我将maven放在我的c驱动器中,并运行mvn-version。它显示版本,我假设安装了maven 现在我试图在cmd中执行一个below命令,但它总是显示错误 mvn archetype:generate -DgroupId=com.selva -DartifactId=SampleApplication -DarchetypeArtifactId=maven-ar

我是eclipse的新手。从今天开始我就开始使用eclipse。 我的需求是在eclipse中生成一个简单的maven项目。因此,我将maven放在我的c驱动器中,并运行mvn-version。它显示版本,我假设安装了maven

现在我试图在cmd中执行一个below命令,但它总是显示错误

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) 在EclipseIDE中,导航到文件>新建>其他…以打开项目创建向导

2) 滚动到Maven文件夹,打开它,然后选择Maven项目。然后选择下一步

3) 您可以选择创建一个简单的项目,也可以放弃此选项。在本教程中,我们将选择简单项目。这将创建一个基本的、支持Maven的Java项目。如果需要更高级的设置,请取消选中此设置,您将能够使用更高级的Maven项目设置功能。保持其他选项不变,然后单击“下一步”

4) 现在,您需要输入有关正在创建的Maven项目的信息。您可以访问Maven文档,更深入地了解Maven坐标()。通常,组Id应该对应于您的组织名称,工件Id应该对应于项目名称。版本由您决定,包装和其他领域也是如此。如果这是一个没有父依赖项的独立项目,则可以保持父项目部分不变。填写适当的信息,然后单击Finish

5) 现在您将注意到您的项目已经创建。您将把Java代码放在/src/main/Java中,资源放在/src/main/resources中,测试代码和资源分别放在/src/test/Java和/src/test/resources中

6) 打开pom.xml文件以查看Maven设置的结构。在此文件中,您可以看到在步骤4中输入的信息。您还可以使用窗口底部的选项卡更改以查看POM.xml选项卡中的依赖项、依赖项层次结构、有效POM以及POM文件的原始xml代码

现在将创建使用Eclipse的Maven java项目


如果Eclipse中没有Maven,请安装m2e。

重复问题。您的解决方案:@dovy,上面的链接解释了如何在eclipse中包含maven。我的问题是为什么我的命令没有执行或生成失败,我还使用上面的链接在eclipse中包含maven。当单击“完成”和“项目未创建”时,无法解析警报框中的原型显示如果我启用了“创建简单项目”复选框“项目已创建但出现错误”pom.xml fileCoreException:无法计算构建计划:Plugin org.apache.maven.plugins:maven编译器Plugin:3.1或其一个依赖项无法解析:未能读取org.apache.maven.plugins:maven编译器Plugin:jar:3.1:ArtifactResolutionException:无法传输工件plugins:maven编译器插件:pom:3.1 from/to central():连接超时