将Maven项目与Java项目结合 [英] Combining a maven project with a java project

查看:120
本文介绍了将Maven项目与Java项目结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我有一个运行服务器的Maven项目(使用Jersey REST API).我也有一个Java项目,我需要将Java项目的所有内容移动到Maven项目中. Maven项目是Java项目的子集.但是,maven项目仅显示java项目的各个部分.但是,我想要一个允许我使用maven并显示java项目中所有其他详细信息的项目.

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.

我会复制并粘贴,但是我使用的是git,所以我也想保留历史记录.

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

我当时想将maven项目嵌套在java项目中会更容易,但是我不知道这是否可能.

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.

程序包浏览器显示了maven项目是java项目的子集.

我尝试过的是将java项目转换为maven项目,然后更新pom.xml,但是它没有链接到web.xml.另外,它尝试使用项目名称TeamProject的名称运行服务器.实际上,它应以名称client_server

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

我正在考虑只是将所有代码复制并粘贴到maven项目中(来自Teamproject java项目).

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

推荐答案

实际上将Java项目嵌套在Maven项目中更有意义,因为这是Maven处理项目生命周期的目的. (同样,默认情况下,Maven还会在src/文件夹中查找源,这将简化将Java项目放在Maven手中的任务)

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)

我会看到几种可能性:

  1. 将Java项目复制到客户端项目的src/中,并相应地更新maven(在pom.xml中)
  2. 使您的Java项目成为Maven项目,并将这两个项目聚集在父pom中(请参阅

在Java项目中嵌套Maven项目并不是那么好,因为Maven只能处理客户端,而不能处理Java项目,然后您会错过Maven提供的众多功能(只是看看它有多么简单).与下载jar并将其手动包含在构建路径中相比,可以获得依赖项

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)

这篇关于将Maven项目与Java项目结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆