简体   繁体   English

如何在现有的netbeans项目中集成maven 2?

[英]How to integrate maven 2 in an existing netbeans project?

How to integrate maven 2 in an existing netbeans project ? 如何在现有的netbeans项目中集成maven 2?

I dont want to do it by creating a new maven web app project and moving my files manually to the new project (as I have versions of this project in my subversion repositories which I wont be able to link if I create new project), rather I need to integrate that in my already existing netbeans project. 我不想通过创建一个新的maven web应用程序项目并将我的文件手动移动到新项目来实现它 (因为我在我的subversion存储库中有这个项目的版本,如果我创建新项目,我将无法链接),而是我需要将它集成到我现有的netbeans项目中。 How do I go about it ? 我该怎么办呢? Would creating a pom.xml work ? 创建一个pom.xml会起作用吗?


Maven 2 already installed on my machine. Maven 2已安装在我的机器上。

What about creating a new Maven Web Project and moving the pom.xml back to your existing Web Project? 如何创建一个新的Maven Web项目并将pom.xml移回现有的Web项目? I mean: 我的意思是:

  1. Backup your projects 备份您的项目
  2. Create a new project with name MavenWebTest 创建一个名为MavenWebTest的新项目
  3. Close your original project 关闭原始项目
  4. Move the pom.xml from the MavenWebTest project to your original project's folder pom.xmlMavenWebTest项目移动到原始项目的文件夹
  5. Modify the pom.xml 's project specific settings (eg project name, dependencies) 修改pom.xml的项目特定设置(例如项目名称,依赖项)
  6. Delete the build.xml and the whole nbproject folder 删除build.xml和整个nbproject文件夹
  7. Move and rename the web folder to src/main/webapp ( webapp is the new name) (use svn mv if you use Subversion) web文件夹移动并重命名为src/main/webappwebapp是新名称)(如果使用Subversion,请使用svn mv
  8. Move src/java to src/main/java ( svn mv here too) src/java移动到src/main/java (这里也是svn mv
  9. Open you project again in Netbeans. 在Netbeans中再次打开你的项目。 It should be a Maven project now. 它现在应该是一个Maven项目。
  10. Delete the unnecessary MavenWebTest project 删除不必要的MavenWebTest项目

Anyway, creating an empty pom.xml also should work. 无论如何,创建一个空的pom.xml也应该有效。 You have to list your dependencies in the pom.xml and you have to set the project's name. 您必须在pom.xml列出依赖项,并且必须设置项目的名称。 Maybe other fine tunings also required to get the same result as Netbeans create without Maven. 也许其他微调也需要得到与没有Maven的Netbeans创建相同的结果。 If you create the pom.xml with Netbeans (the MavenWebTest above) I suppose that most of Netbeans specific stuff already will be there. 如果您使用Netbeans(上面的MavenWebTest)创建pom.xml ,我想大多数Netbeans特定的东西已经存在。

If you are new to Maven I suggest you to check the free pdf/html books on Sonatype's website . 如果您是Maven的新手,我建议您查看Sonatype网站上的免费pdf / html书籍。

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

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