[英]How a build library jar of spring boot application using maven
I have an application A which contains code to fetch records from dB and some other functionality.我有一个应用程序 A,其中包含从 dB 和其他一些功能中获取记录的代码。 I want to use the same in another project B and use A as dependency.
我想在另一个项目 B 中使用它并使用 A 作为依赖项。 Even if spring boot apps are not recommended to be used as library I have this use case bcs app A is a batch application and doesn't keep running so no option of rest call.
即使不建议将 spring 引导应用程序用作库,我也有此用例 bcs 应用程序 A 是批处理应用程序并且不会继续运行,因此没有 rest 调用选项。 Issue is when I try to create the jar it is created as spring boot jar or if I create a normal jar it doesn't have the required dependencies and fails at runtime as class not found.
Issue is when I try to create the jar it is created as spring boot jar or if I create a normal jar it doesn't have the required dependencies and fails at runtime as class not found. It seems dependencies from parent project of A are not included during jar creation.
在 jar 创建期间似乎不包括来自 A 的父项目的依赖项。 Is there a recommenced way of generating the jar using maven.
是否有使用 maven 生成 jar 的推荐方法。
To elaborate on what chrylis said:详细说明 chrylis 所说的话:
Create a project or module C that contains everything that both A and B need.创建一个项目或模块 C,其中包含 A 和 B 所需的一切。 Use it as dependency in A and B.
将其用作 A 和 B 中的依赖项。
The easiest way to handle this is to have a multi-module-project with A, B and C, but you can also have three separate projects.处理此问题的最简单方法是拥有一个包含 A、B 和 C 的多模块项目,但您也可以拥有三个独立的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.