[英]How to create a Maven project in Eclipse
I want to create a web application project in Eclipse with Maven. 我想用Maven在Eclipse中创建一个Web应用程序项目。 Everytime I try to create the project I get an error as "Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories" .
每次尝试创建项目时,都会收到错误消息“无法从任何已配置的存储库解析原型org.apache.maven.archetypes:maven-archetype-webapp:RELEASE” 。
I have checked for solutions presented in other questions tried them, but none of them solved the issue. 我已经检查了其他尝试过的问题中提出的解决方案,但没有一个解决了问题。 I have also changed my settings.xml file to point it to proxy even that didn't help.
我也更改了settings.xml文件,使其指向代理,即使这样做没有帮助。 I also tried deleting the repositries folder in .m2 .
我还尝试删除.m2中的存储库文件夹。
Please suggest some solutions for this 请为此提出一些解决方案
- Open Window > Preferences
打开窗口>首选项
- Open Maven > Archetypes
打开Maven>原型
- Click 'Add Remote Catalog' and add the following:
点击“添加远程目录”并添加以下内容:
- Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
目录文件: http : //repo1.maven.org/maven2/archetype-catalog.xml
- Description: maven catalog
说明:Maven目录
That is quite a weird issue ... however m2eclipse gave me my fair share of problems when I tried to create my projects. 这是一个很奇怪的问题……但是当我尝试创建项目时,m2eclipse给了我很多问题。 In fact, I ended up creating the archetypes myself!
实际上,我最终自己创建了原型!
Let me share my maven 3 POM file: 让我分享我的Maven 3 POM文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!-- add your dependencies here -->
</dependencies>
<build>
<finalName>example-project</finalName>
<pluginManagement>
<plugins>
<!-- v. useful! m2eclipse sometimes fails to see it as a
dynamic web app project in Eclipse. Declaring this plugin
would help eclipse recognize its nature (i.e. a Java
project requesting at least JDK1.7+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Running mvn eclipse:eclipse
on this project should work. 在此项目上运行
mvn eclipse:eclipse
应该可以。 You can safely import to eclipse as a maven project as well ( File > Import > Existing Maven Projects
) If it doesn't, then you should consider re-installing a fresh copy of maven. 您也可以安全地将其作为maven项目导入(eclipse)(“
File > Import > Existing Maven Projects
)。如果没有,则应考虑重新安装maven的新副本。
Let me know if you manage to get it up and running. 如果您设法启动并运行它,请告诉我。 :)
:)
I was recently struggling to create a new Maven project in Eclipse. 我最近正在努力在Eclipse中创建一个新的Maven项目。 Trying to create a Dynamic Web Project first and then converting it into a Maven project did not work (none of the Java integration was working and my code wouldn't even compile)!
尝试先创建一个动态Web项目,然后再将其转换为Maven项目是行不通的(Java集成都无法正常工作,我的代码甚至都无法编译)!
The following article describes how to create a Maven project in Eclipse. 下面的文章描述了如何在Eclipse中创建Maven项目。 The tutorial recommends skipping the archetype part, which might solve the issue described in the original question:
本教程建议跳过原型部分,这可能会解决原始问题中描述的问题:
https://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/ https://www.tech-recipes.com/rx/39279/create-a-new-maven-project-in-eclipse/
If that doesn't work for you, perhaps doing a clean install with the latest version of Eclipse, in a new directory, may help. 如果这对您不起作用,也许可以在新目录中使用最新版本的Eclipse进行全新安装可能会有所帮助。 What you described might just be a bug in Eclipse or one of its installed plugins.
您所描述的可能只是Eclipse中的错误或其安装的插件之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.