spring-boot - 不知道如何将连接面包含到多模块 gradle 构建中
问题描述
我的一个旧应用程序是 Java 8 Enterprise mololith,我想迁移它。
我想通过使用连接面将其迁移到包括primefaces、myfaces和omnifaces的spring boot项目中,并将其拆分为更小的部分(多模块项目)以便更好地维护。
所以我将项目分成以下模块,成为一个工作原型:
模块的简短描述:
- Common / ComDb :这里只生成 JPA 实体/直接从数据库分类,所有模块都可以使用哪些类
- Libraries / LibPrimeFaces :这里只是最新的 primefaces 精英 JAR,应该在 SpringBoot 中使用
- Libraries / LibPrimeFacesTheme :这是一个购买的 primefaces 主题,将捆绑并包含在生成的 JAR 中。
- Services / * :应该使用的每个spring boot服务都位于这里,因此可以在主应用程序中使用,也可以通过REST从外部服务中使用
- 应用程序:这是 Spring Boot 应用程序,它应该包括上述所有内容 - 最后甚至是一个可运行的 jar 文件
现在对我来说的问题是 gradle 的使用,这对我来说是全新的:
我不知道如何使用 gradle 将 joinfaces 与我从精英订阅、omnifaces 3 和 myfaces 购买的 primefaces-8.0.5.jar 结合起来。
大多数手册适用于 maven,但如果我转换脚本,它们似乎不适用于 gradle。
目前整个项目编译并启动没有任何错误,但现在我找不到在像我这样的多模块环境中使用连接面和 gradle 的工作示例。
以下是主要的 gradle 脚本:
根脚本:
gradle.properties(保存版本):
VersionSpringBoot=2.3.5.RELEASE
VersionSpringDependencyManagement=1.0.10.RELEASE
VersionPrimeFaces=8.0.5
settings.gradle(包括和名称):
rootProject.name = 'EcoCalcDD4Web'
include 'Common:ComDb'
include 'Libraries:LibPrimeFaces'
include 'Services:ServiceConfigWebManagement'
include 'Application'
build.gradle(主构建文件):
buildscript {
repositories {
mavenCentral()
maven {
url './Libraries/LibPrimeFaces'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${VersionSpringBoot}")
}
}
allprojects {
group = 'com.skf.rocket'
version = '1.0.0'
repositories {
mavenCentral()
maven {
url './Libraries/LibPrimeFaces'
}
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
maven {
url './Libraries/LibPrimeFaces'
}
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${VersionSpringBoot}")
}
}
dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
}
这里是应用程序 build.gradle - JoinFaces 应该与我的 primefaces、omnifaces 和 myfaces 一起使用的文件。在这里,我不知道要添加什么才能开始使用 joinfaces:
apply plugin: 'org.springframework.boot'
bootJar {
mainClassName = "com.skf.rocket.EcoCalcDd4WebRocket"
}
// Maven dependencies
dependencies {
// Internal dependencies
api project(':Common:ComDb')
// Implementation project('Libraries:LibPrimeFacesTheme')
api project(':Services:ServiceConfigWebManagement')
// External dependencies
// JoinFaces + MyFaces + PrimeFaces - TODO ??
// Development tools with HotReDeploy
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// Automatically configuration
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
// Lombok - Utility
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// Global cache
implementation 'org.springframework.boot:spring-boot-starter-cache'
// Data access + MS SQL driver
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
// Data validation
implementation 'org.springframework.boot:spring-boot-starter-validation'
// Web + RestService
implementation 'org.springframework.boot:spring-boot-starter-web'
// Session management
implementation 'org.springframework.session:spring-session-core'
// Boot Acturator - Application monitoring and alive checks
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
// Unit test
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
解决方案
首先,您应该看看这些资源:
- https://docs.gradle.org/current/userguide/intro_multi_project_builds.html
- https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
- https://docs.joinfaces.org/4.3.4/reference/#_gradle
- https://docs.joinfaces.org/4.3.4/reference/#_example_using_myfaces_instead_of_mojarra
- https://github.com/joinfaces/joinfaces-gradle-jar-example
要开始使用 JoinFaces,您需要依赖org.joinfaces:jsf-spring-boot-starter
. 因为您想使用 MyFaces 而不是 Mojarra,所以您必须将其排除并拉取 MyFaces。
我将从这些依赖项开始:
implementation ("org.joinfaces:jsf-spring-boot-starter") {
exclude module: "mojarra-spring-boot-starter"
}
implementation "org.joinfaces:myfaces-spring-boot-starter"
implementation "org.joinfaces:omnifaces1-spring-boot-starter"
推荐阅读
- javascript - SVG元素跟随光标
- reactjs - React - 无法显示路径存储在 json 文件中的 svg 图像
- android - Sqlite 在应用程序的生命周期内打开连接
- vue.js - Vue-i18next:为不同的国家维护不同的语言
- r - 用 DT 包输出时可以更改 R 默认表长度吗?
- python - 如何从 MAC 地址中删除分隔符
- javascript - 为什么在 Fetch 调用中使用 Async/Await
- php - Laravel:搜索条件关系并检索记录
- python - 传递新数据时无法更新图形(“动态图”)
- cplex - OPL CPLEX - 使用具有不同 KPI 的多目标优化