记录使用springboot2的gradle,方便以后快速搭项目
使用idea创建gradle的java项目后
//settings.gradle
pluginManagement {
repositories {
maven {
url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'https://maven.aliyun.com/repository/google' }
maven {
url 'https://maven.aliyun.com/repository/central' }
maven {
url 'https://maven.aliyun.com/repository/gradle-plugin' }
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == 'org.springframework.boot') {
useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
}
}
}
}
rootProject.name = 'spirnggradle'
//build.gradle
plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group 'com.ddddd'
version '1.0'
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven {
url 'http://maven.aliyun.com/nexus/content/repositories/central/' }
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.springframework.boot:spring-boot-devtools'
// 加载外部jar
// compile files('lib/ojdbc6.jar')
// 去除内置tomcat
// providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
test {
useJUnitPlatform()
}
其他的类与test与mave一样
springboot2的maven项目模板
右边gradle窗口的项目打包与编译
Run Configurations下是test
tasks–build–bootjar编译jar包,在build/libs下