从Maven将多模块项目构建到一个war文件中 [英] Building multi-module project from Maven into one war file

查看:213
本文介绍了从Maven将多模块项目构建到一个war文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经问过我的问题,我知道,但是我想我尝试做一些稍有不同的事情,而现有的答案是不合适的.

My question has been asked before, which I know, but I think that I am trying to do something slightly different, where existing answers are not appropriate.

本质上,我确实希望在Eclipse中有多个项目,这些项目将(最好)构建到一个最终的WAR文件中.理想的情况是这样:

Essentially, I do want to have multiple projects in Eclipse that will be built (preferably) into one final WAR file. Ideally like this:

root - pom.xml
|___ java-app
|___ web-service-v1
|___ web-service-v2
|___ web-service-v3
|___ rest-service
|___ batch-service

将Java App想象成实际的应用程序,并且每个附加组件都作为Java App本身的分离视图层运行.最终,Java应用程序将在tomcat实例中运行,并由不同的模块提供服务.我希望所有不同的模块也都可以在同一个Spring容器中运行.

Imagine the Java App as the actual application, and each additional component runs as a decoupled view layer for the Java App itself. Ultimately, the Java application will be running in a tomcat instance, with the different modules providing their services. I would like all the different modules also to run in the same Spring container.

我不知道在Maven模块中运行是执行此操作的最佳方法,但我真的希望将每个组件都放在一个单独的Eclipse项目中,最终将它们组合在一起.

I don't know that running in Maven modules is the best way of doing this, but I would really prefer to have each component in a separate Eclipse project that ultimately get built together.

任何人都可以提供有关我如何使用Maven构建它的任何建议吗?

Can anyone provide any suggestions as to how I would use Maven to build this?

推荐答案

只需创建一个单独的war模块:

Just make a separate war module:

root - pom.xml (packaging: pom!!!)
|___ java-app
|___ web-service-v1
..
+--- mod-war (pom.xml)

,然后将要添加到war文件中的模块的依赖项放入pom中.

and put the dependencies of the modules you would like to have added to the war file into the pom and that's it.

这篇关于从Maven将多模块项目构建到一个war文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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