简体   繁体   English

包括 maven 灯罩 jar 到其他灯罩 jar

[英]include maven shade jar into other shade jar

I have two Java projects data-service app and data-report app, data service app produces certain data which is used for some processing and the data-report app should use data-service app to use the data produced by it to produce some reports, both the apps should be built as Jar file hence i am planning to use maven shade plugin as they use lot of jars.我有两个 Java 项目数据服务应用程序和数据报告应用程序,数据服务应用程序产生某些数据用于某些处理,数据报告应用程序应该使用数据服务应用程序使用它产生的数据来生成一些报告,这两个应用程序都应该构建为 Jar 文件,因此我计划使用 maven 阴影插件,因为它们使用了很多 jars。

I need to include data-service as dependency in data-report ( i cannot use any other technique like rest due to certain limitations) i have below two issues with this approach我需要在数据报告中包含数据服务作为依赖项(由于某些限制,我不能使用任何其他技术,如 rest)我有以下两个问题与这种方法

1) Both the apps have log4j file and data.properties, both the files have properties specific to each app, can you please let me know how to handle such scenario, i tried resource-transformers but not working please let me know if anybody was successful able to use it. 1) 这两个应用程序都有 log4j 文件和 data.properties,这两个文件都有每个应用程序特定的属性,你能告诉我如何处理这种情况吗,我尝试了资源转换器但没有工作请告诉我是否有人成功能够使用它。

2) since both apps use similar library like spring and hibernate will it eliminate duplicates? 2)由于这两个应用程序都使用类似的库,如 spring 和 hibernate 会消除重复吗?

3) lets day i am usign gson version 1 in one app and gson versoin 1.2 how will it handle such cases? 3)让我在一个应用程序中使用 gson 版本 1 和 gson 版本 1.2 将如何处理这种情况?

4) Is my approach right? 4)我的方法对吗? i dont want to use maven module due to some restrictions.由于某些限制,我不想使用 maven 模块。

No, each jar should either be a library or an executable jar (not both).不,每个 jar 都应该是库或可执行 jar(不能同时是两者)。 A library should be build without including the libraries (so no shade plugin).应该在包含库的情况下构建库(因此没有阴影插件)。

So if you have classes that are used by both apps, build a third jar as a library and use it in both apps as dependency.因此,如果您有两个应用程序都使用的类,请构建第三个 jar 作为并在两个应用程序中使用它作为依赖项。

So either you have three different projects, or you construct a multi-module project of the three, but that is up to the circumstances.因此,您要么拥有三个不同的项目,要么构建三个不同的多模块项目,但这取决于具体情况。

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

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