简体   繁体   English

创建一个Maven项目以用作另一个项目中的jar库

[英]Create a maven project to be used as a jar library in another project

I want that a maven project can be used as a black box jar. 我希望一个Maven项目可以用作黑匣子。 This is needed because second project was born its way, and I don't want to integrate its code by hand. 之所以需要这样做,是因为第二个项目以它的方式诞生,我不想手工集成其代码。 So the best way is that this project is going to save it's data on db, but it should use a service offered by the "wrapper" project to save them. 因此,最好的方法是该项目将其数据保存在db上,但它应使用“包装器”项目提供的服务来保存它们。

The idea is simple, the secondary project can expose just a method to which I will pass the service that offers the save method as a parameter. 这个想法很简单,辅助项目只能公开一个方法,我将传递将save方法作为参数的服务传递给该方法。

The secondary project should not have configuration files, but should rely on the father application's properties. 辅助项目不应具有配置文件,而应依赖于父应用程序的属性。

Any idea to do this fast and almsot good? 有什么想法可以做到这一点又快又好吗? Thanks for any suggestion. 感谢您的任何建议。

EDIT 2013/03/07: The idea behind this is that the second project should generate a classic jar library that looks a properties file into the classpath of the host project. EDIT 2013/03/07:其背后的想法是,第二个项目应生成一个经典的jar库,该库在宿主项目的类路径中查找属性文件。 Something like Quartz/Spring/... you import jar and you provide the properties file. 像Quartz / Spring / ...之类的东西,您导入jar并提供属性文件。

I just defined some classes to load properties from the classpath, and some interfaces to make the two projects interact. 我只是定义了一些类来从类路径中加载属性,还定义了一些接口来使两个项目交互。

In pom.xml of the parent project I imported the child project excluding it's dependencies to avoid conflicts. 在父项目的pom.xml中,我导入了子项目,排除了它的依赖项以避免冲突。

It was a pretty easy task at the end. 最后,这是一个非常简单的任务。

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

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