gpt4 book ai didi

java - Spring Boot gradle多模块应用

转载 作者:太空宇宙 更新时间:2023-11-04 09:03:41 24 4
gpt4 key购买 nike

我有一个带有多个模块的 Spring Boot 应用程序(gradle),但在构建应用程序时遇到问题。下面是我的 gradle

build.gradle(主应用程序)

plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}

group = 'net.sagati'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compile project(':my-pet-clinic-data')
compile project(':my-pet-clinic-web')
}

test {
useJUnitPlatform()
}

build.gradle - 数据层。第一个模块

plugins {
id 'java'
}

group 'net.sagati'
version '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
}
test {
useJUnitPlatform()
}
bootJar {
enabled = false
}

jar {
enabled = true
}

build.gradle - Web 层第二个模块

plugins {
id 'java'
}

group 'net.sagati'
version '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
}
test {
useJUnitPlatform()
}
bootJar {
enabled = false
}

jar {
enabled = true
}

********************错误消息********************************************

A problem occurred evaluating project ':my-pet-clinic-data'.
> Could not find method bootJar() for arguments [build_iptt1011gxtkxqsop7ht18yc$_run_closure4@45139c47] on project ':my-pet-clinic-data' of type org.gradle.api.Project.

如有任何帮助,我们将不胜感激。

更新

删除后

bootJar {
enabled = false
}

我遇到以下错误

Execution failed for task ':my-pet-clinic-data:compileJava'.
> Could not resolve all files for configuration ':my-pet-clinic-data:compileClasspath'.
> Could not find org.projectlombok:lombok:.
Required by:
project :my-pet-clinic-data
> Could not find org.springframework.boot:spring-boot-starter-data-jpa:.
Required by:
project :my-pet-clinic-data

最佳答案

更新的问题是由于没有任何依赖项版本引起的。

在应用Spring boot Gradle插件时,它会应用Spring依赖管理插件并配置Spring boot BOM。 documentation 对此进行了解释。 .

但是您的数据和 Web 项目仅应用 java 插件,因此不支持 BOM。我建议查看 native Gradle BOM support 。可以在上面链接的 Spring 文档第 3.2 节中找到一种具有性能成本的替代方案。

关于java - Spring Boot gradle多模块应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60482495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com