咱們不基於start.spring.io 來建立項目,由於其中有不少配置是咱們不須要的;html
第一步:FIle-->New-->Project java
Finish 結束;git
第二步:展現完成項目 github
第三步:建立多模塊(module) web
Finish 完成 並刪除模塊以外的src; 按照第二步驟再次建立一個模塊,完成多模塊項目;spring
多模塊 project項目搭建完成 app
//應用於gradle 編譯
buildscript {
//定義
ext {
springBootVersion = "2.0.5.RELEASE"
}
repositories {
//maven 中央倉庫
mavenCentral()
}
dependencies {
// 指定gradle spring boot plugin 版本 用於spring boot 版本依賴控制
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
// 全部子項目的通用配置
subprojects {
//指定中央倉庫 項目使用
repositories {
//maven 中央倉庫
mavenCentral()
}
//應用插件
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
//用於spring boot 版本jar依賴
apply plugin: 'io.spring.dependency-management'
//指定jdk版本
sourceCompatibility = 1.8
//設置group id
group 'com.project'
//設置版本
version '1.0.0'
description 'projec'
//依賴
dependencies {
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter')
}
//這裏必定得要。在多模塊下,否則編譯失敗,由於不會把信賴模塊給打包。
jar {
enabled = true
}
}
複製代碼
dependencies {
compile project(":project-core") compile ("org.springframework.boot:spring-boot-starter-web") compile ("io.springfox:springfox-swagger2:2.6.1") compile ("io.springfox:springfox-swagger-ui:2.6.1") //swagger 自定義ui 調用地址:http://${host}:${port}/docs.html 新頁面 compile ("com.github.caspar-chen:swagger-ui-layer:0.0.6") } 複製代碼
講解maven
最外層的build.gradle 中分爲 兩大塊 buildscript{} 和 subprojects{};ide
//應用於gradle 編譯
buildscript {
//定義
ext {
springBootVersion = "2.0.5.RELEASE"
}
repositories {
//maven 中央倉庫
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
複製代碼
// 全部子項目的通用配置
subprojects {
//指定中央倉庫 項目使用
repositories {
//maven 中央倉庫
mavenCentral()
}
//應用插件
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
//指定jdk版本
sourceCompatibility = 1.8
//設置group id
group 'com.project'
//設置版本
version '1.0.0'
description 'projec'
//依賴
dependencies {
testCompile('org.springframework.boot:spring-boot-starter-test')
compile('org.springframework.boot:spring-boot-starter')
}
//這裏必定得要。在多模塊下,否則編譯失敗,由於不會把信賴模塊給打包。
jar {
enabled = true
}
}
複製代碼