eclipse 在eclipse中添加maven依赖

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34349678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:59:28  来源:igfitidea点击:

Adding maven dependencies in eclipse

javaeclipseweb-servicesrestmaven

提问by allDroid

I am using eclipse mars,in that I am creating a rest webservice by refering thislink.

我正在使用 eclipse mars,因为我正在通过引用链接创建一个休息网络服务。

As mentioned in this link I have to add maven dependencies.I tried googling it but didn't find any solution for it.

正如此链接中所述,我必须添加 maven 依赖项。我尝试使用谷歌搜索它但没有找到任何解决方案。

How to add it to my dynamic web project created ?or is it already available in my eclipse,if it so then how could I add jar files.

如何将它添加到我创建的动态 Web 项目中?或者它是否已经在我的 eclipse 中可用,如果是,那么我如何添加 jar 文件。

采纳答案by shraddha bhardwaj

If you convert your project to maven project pom.xmlwill be automatically created,if not
1- Create pom.xmlfile -by clicking on project directory->new->file
2- search frm google maven dependencies for ex: if you want to download spring-context.jar ,then search for maven spring context ,you will get groupidand artifactidpaste it in pom.xmlfile.jars will be automatically downloaded.

如果您将项目转换为 maven 项目pom.xml将被自动创建,如果不是
1- 创建pom.xml文件 - 通过单击项目目录->新建->文件
2-搜索 frm google maven 依赖项例如:如果您想下载 spring-context.xml 文件。 jar ,然后搜索 maven spring 上下文,您将获取groupidartifactid粘贴到文件中pom.xml。jars 将被自动下载。

回答by Akhil Menon

Don't create a dynamic project, instead :

不要创建动态项目,而是:

1)Create a new maven project in eclipse from File-->New-->Other and select Maven

1)在eclipse中从File-->New-->Other创建一个新的maven项目并选择Maven

2)Give location of project and click next

2)给出项目的位置,然后单击下一步

3)From the archetype select maven-archetype-webapp and click next

3)从原型中选择 maven-archetype-webapp 并单击下一步

4)In Group Id give the package name like "com" and in Artifact Id give appropriate name so by all this a package will be created

4)在 Group Id 中给出包名称,如“com”,在 Artifact Id 中给出适当的名称,因此将创建一个包

5)Now your maven project is ready, to add the jar files means you need to add dependencies

5)现在你的maven项目已经准备好了,添加jar文件意味着你需要添加依赖项

6)So goto mvnrepository.com and search for the jar files you need to add,select the latest stable release and then copy the dependency from the Maven Tab

6)所以去mvnrepository.com搜索你需要添加的jar文件,选择最新的稳定版本,然后从Maven选项卡中复制依赖

7)Now open pom.xml from the created project and add the copied dependency inside the dependencies tag and do a ctrl + s

7)现在从创建的项目中打开 pom.xml 并将复制的依赖项添加到依赖项标记中并执行 ctrl + s

8)It will automatically download and add the required jar files to your library

8)它会自动下载所需的jar文件并将其添加到您的库中