问题描述
我有一个使用Spring Boot创建的现有战争项目.如何将其打包在具有EJB模块的EAR中?
I have an existing war project created using spring boot. How to package it within an EAR which has an EJB module?
有什么方法可以将模型和dao包移至EJB模块,然后将其注入WAR模块?
Is there any way to move the model and dao packages to EJB module and injecting it with WAR module?
推荐答案
您必须使用依赖项管理系统.
You have to use the dependency management system.
它允许您将Spring Boot WAR
模块项目的父级设置为与spring-boot-starter-parent
不同的父级.这样就有可能以与其他任何方式相同的方式将WAR
项目包含到EAR
中.
It allows you to set the parent of Spring Boot WAR
module project to the different from the spring-boot-starter-parent
. Then it's would be possible to include the WAR
project into the EAR
one in the same way like any other.
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...现在,您可以按通常方式使用所有Spring Boot启动器依赖项:
... now you can use all the Spring Boot starter dependencies in the usual way:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
您必须在模块项目级别指定的启动程序依赖项,而依赖项管理配置可以在两个项目中指定-围绕整个EAR
项目,或者在每个项目上分别指定,具体取决于应用程序的要求.
The starter dependencies you've to specify at the module projects level, while the dependency management configuration may be specified at the both ones - around the whole EAR
projects or individually on each of them, depending on the app requirements.
这篇关于将Spring Boot集成到EAR项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!