반응형
다중 모듈 Spring Boot 프로젝트의 Gradle 종속성 플러그인
Gradle 플러그인을 사용하는 다중 모듈 프로젝트에서 올바른 Gradle 구성은 어떻게 나타납니까?spring-boot-dependencies
그리고.spring-boot
?
다음과 같은 프로젝트 설정이 있습니다.
parent
|
+ build.gradle
|
+ alpha
| |
| + build.gradle
|
+ beta
| |
| + build.gradle
- 그
parent
모듈에 공통 프로젝트 구성이 포함되어 있습니다. - 그
alpha
module은 spring-boot-dependencies bom에 지정된 버전 번호를 사용하여 종속성을 가져오는 모듈이지만 의 결과는 표준 jar입니다. - 그
beta
모듈은 다음에 의존하는 모듈입니다.alpha
실행 가능한 Spring Boot jar 파일(모든 종속성 포함)이 생성됩니다.결과적으로, 이 프로젝트는 두 가지를 모두 필요로 합니다.spring-boot-dependencies
뿐만 아니라spring-boot
플러그인
Gradle 파일을 DRY 상태로 유지하기 위해 공통 모듈 스크립트를 부모님의 파일에 추출했습니다.build.gradle
파일.
실행 시도 횟수$ gradle build
아래의 프로젝트 구성을 사용하면 다음과 같은 결과를 얻을 수 있습니다.
> Plugin with id 'io.spring.dependency-management' not found.
부모의 기쁨빌드
allprojects {
group = "com.example"
version '0.0.1-SNAPSHOT'
ext {
dependencyManagementPluginVersion = '0.5.3.RELEASE'
springBootVersion = '1.3.0.RC1'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
}
subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
buildscript {
repositories {
jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:${dependencyManagementPluginVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
// mavenBom("org.springframework.boot:spring-boot-starter-parent:${springBootVersion}")
}
}
}
알파 빌드.그레이들
dependencies {
compile('org.springframework:spring-web')
}
베타 그라들빌드
apply plugin: 'spring-boot'
dependencies {
compile project(':alpha')
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-web')
}
댓글:
알고 보니parent/build.gradle
다음과 같은 방식으로 재배열해야 합니다.
buildscript {
ext {
dependencyManagementPluginVersion = '0.5.3.RELEASE'
springBootVersion = '1.3.0.RC1'
}
repositories {
jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:${dependencyManagementPluginVersion}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
allprojects {
group = "com.example"
version '0.0.1-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
}
subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
// mavenBom("org.springframework.boot:spring-boot-starter-parent:${springBootVersion}")
}
}
}
문제는 그 사실에 있습니다.buildscript
하위 프로젝트의 블록은 실제로 잘 구성되었지만...엉뚱한 곳에이것.subprojects
블록은 하위 프로젝트와 관련이 있지만 선언된 스크립트에서 평가되며 적용하려는 플러그인에 대해 선언된 종속성이 없습니다.
언급URL : https://stackoverflow.com/questions/33706957/gradle-dependency-plugin-in-a-multi-module-spring-boot-project
반응형
'programing' 카테고리의 다른 글
MongoDB(pymongo를 통해)를 효율적으로 인식하지 못하는 경우 쿼리 (0) | 2023.07.02 |
---|---|
열 필드에 대한 두 행 간의 차이를 얻는 방법은 무엇입니까? (0) | 2023.07.02 |
C 컴파일러가 외부 이름에 밑줄을 추가하는 이유는 무엇입니까? (0) | 2023.07.02 |
Git는 왜 내가 원점으로 밀어 넣으려고 할 때 "그렇게 먼 '원점'은 없다"고 말합니까? (0) | 2023.07.02 |
SQL # 기호는 무엇을 의미하며 어떻게 사용됩니까? (0) | 2023.06.27 |