咱们不基于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
}
}
复制代码