简体   繁体   English

如何将存在的Java项目转换为maven项目?

[英]How do I convert a exist Java project to maven project?

I've installed m2eclipse, and using the embedded Maven3. 我已经安装了m2eclipse,并使用了嵌入式Maven3。

Now I want to add dependencies to my project(there are existing jars), but the search result is always 0, how do I deal with this ? 现在我想将依赖项添加到我的项目(有现有的jar),但搜索结果始终为0,我该如何处理?

I don't want to download all jars for now, just want to create the dependencies now. 我现在不想下载所有的jar,只是想现在创建依赖项。

在此输入图像描述

"spring" and "spring" are not valid specifiers for the Spring libraries. “spring”和“spring”不是Spring库的有效说明符。

Here is a link to a helpful article about artifact names for Spring: 这是一篇关于Spring的工件名称的有用文章的链接:

http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/ http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/

You should be using names like: 您应该使用以下名称:

    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>

if you want to convert a project to eclipse maven project, you can open terminal and run 如果你想将项目转换为eclipse maven项目,你可以打开终端并运行

mvn eclipse:eclipse

or convert to idea maven project: 或转换为idea maven项目:

mvn idea:idea

Try searching for spring-context instead of spring . 尝试搜索spring-context而不是spring If you are not sure about the name of the artifact you are looking for you can use wildcards, eg *spring*. 如果您不确定要查找的工件的名称,可以使用通配符,例如*spring*.

The dialog in your question is a bit confusing. 您问题中的对话框有点令人困惑。 It's actually two dialogs and should be using tabs. 它实际上是两个对话框,应该使用选项卡。 In the upper part, you can manually add a dependency if you happen to know all the details. 在上半部分,如果您碰巧知道所有细节,可以手动添加依赖项。

In the lower part, you can search for dependencies. 在下半部分,您可以搜索依赖项。 The search will only work if you leave the fields at the top empty. 仅当您将顶部的字段留空时,搜索才有效。

Let me see, you want to use along with the maven dependencies existing in the project, right? 让我看看,您希望与项目中存在的maven依赖项一起使用,对吧?

Assuming your project structure already in structured maven, you can follow this tip below, but beware, i think maybe you can have some sort of conflict between dependencies.. 假设你的项目结构已经在结构化的maven中,你可以按照下面的提示,但要注意,我想也许你可能会在依赖关系之间产生某种冲突。

Use the website below to browse dependencies: 使用以下网站浏览依赖项:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM