Combining a maven project with a java project

女生的网名这么多〃 提交于 2019-12-08 03:17:17

问题


Currently, I have a maven project that has a server running (using Jersey REST API). I also have a java project, I need to move all the contents of the java project into the maven project. The maven project is a subset of the java project. However, the maven project only displays the parts of the java project. However, I want a project that allows me to use maven and displays all of the other details from the java project.

I would've copied and pasted however I'm using git so I want to also preserve history.

I was thinking it would be easier to nest the maven project inside the java project but I don't know if that's possible.

Here's a picture of my package explorer to help explain everything.

Package explorer showing the maven project being a subset of the java project.

What I've tried is converting the java project into a maven project and then updating the pom.xml but then it doesn't link to the web.xml. Also, it tries to run the server with the name of the project name TeamProject. When infact it should run the url with the name client_server

I was considering just copying and pasting all the code into the maven project (from the Teamproject java project).


回答1:


Actually nesting the java project inside the Maven project makes more sense, as it is the purpose of Maven to handle a project lifecycle. (also by default Maven will look for sources in the src/ folder which should ease the task of putting your Java project inside Maven's hands)

There are several possibilities I would see:

  1. Copy your java project in the src/ of your client project and update maven accordingly (within the pom.xml)
  2. Make your Java project a Maven project and aggregate the two projects in a parent pom (see Multi module maven project example)
  3. Make your Java project a Maven project, and decide of a "Master" project between it and the client and compose one with the other (not sure that's a great solution)

Nesting your Maven project inside the Java project would not be so great because Maven could only handle the client and not your Java project, and then you'd miss on numerous functionalities offered by Maven (just look at how simple it is to get dependencies compared to downloading a jar and including it on the build path manually)



来源:https://stackoverflow.com/questions/42447590/combining-a-maven-project-with-a-java-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!