首页 > 解决方案 > 不知道如何将连接面包含到多模块 gradle 构建中

问题描述

我的一个旧应用程序是 Java 8 Enterprise mololith,我想迁移它。

我想通过使用连接面将其迁移到包括primefaces、myfaces和omnifaces的spring boot项目中,并将其拆分为更小的部分(多模块项目)以便更好地维护。

所以我将项目分成以下模块,成为一个工作原型:

项目概况

模块的简短描述:

现在对我来说的问题是 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()
}

标签: spring-bootgradlejoinfaces

解决方案


首先,您应该看看这些资源:

要开始使用 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"

推荐阅读