【发布时间】:2020-01-16 05:49:06
【问题描述】:
我是 gradle 新手。我正在尝试在 STS 中创建 spring boot gradle mutli 项目,但我不明白如何创建。我能够创建单个项目。 所以帮助我如何创建多项目。
根项目:nn-backend
build.gradle:
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.nn'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
allprojects {
group = 'com.nn'
//version = rootProject.version
//sourceCompatibility = 1.8
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
mainClassName = 'com.cc.CcAdminApplication'
version = rootProject.version
ext {
set('springCloudVersion', 'Greenwich.RC2')
}
configurations {
provided
compile.extendsFrom provided
compile.exclude module: 'log4j-slf4j-impl'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/milestone" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url 'https://repo.spring.io/libs-release' }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-log4j2')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter-logging')
compile('org.apache.commons:commons-lang3:3.6')
provided group: 'org.projectlombok', name: 'lombok', version: '1.16.20'
compile group: 'com.vaadin.external.google', name: 'android-json', version: '0.0.20131108.vaadin1'
}
}
settings.gradle:
rootProject.name = 'nn-backend'
include ':nn-model'
include ':nn-admin'
include ':nn-common'
include ':nn-filters'
子项目:nn-common build.gradle:
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.nn'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
子项目:nn-过滤器 build.gradle:
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.nn'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
compile project(':nn-common')
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
【问题讨论】:
-
首先你需要看看所有的依赖会被共享,然后你在根项目上创建。
-
@JonathanJohx 如何创建根项目
-
我发布了我提到的答案
标签: spring spring-boot gradle spring-boot-gradle-plugin