我试图将项目从SpringBoot 1.5。+升级到2. +,它并不那么难,我只需更改几行代码。但我还是坚持Gradle。我一直在关注类路径上的注释过程,并且我试图在本网站的另一篇文章中进行更改。但是,按照我在此处和其他网站上发现的说明,我仍然会收到警告。
正如您将看到我改为使用boot jar,您将在我的两个注释流程行下面看到注释掉的代码。这就是我发现我应该改变但不起作用的东西。
例如:将compileOnly
替换为两行annotationProcessor
&我为lombok和spring-boot-configuration-processor尝试过的implementation
。
buildscript {
ext {
springBootVersion = '2.0.2.RELEASE'
}
repositories {
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'io.spring.gradle:propdeps-plugin:0.0.9.RELEASE'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
apply plugin: 'maven'
//apply plugin: 'war'
//processResources {
// expand(project.properties)
//}
version = '0.0.1'
sourceCompatibility = 1.8
//war {
// baseName = 'goolge-places'
// // version = '0.5.0'
//}
bootJar {
launchScript()
}
//springBoot {
// executable = true
//}
repositories {
jcenter()
mavenCentral()
/*
// Private Oracle Maven repo
maven {
credentials {
username '****'
password '****'
}
name "maven.oracle.com"
url('https://maven.oracle.com/')
}
*/
}
configure(allprojects) {
apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
}
// Change the output directory for the main source set back to the old path
// Gradle 4.0 change Deprecated. gone in version 5.0
//sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
dependencies {
runtime('org.springframework.boot:spring-boot-devtools')
compile 'com.google.maps:google-maps-services:0.1.20'
compile('org.springframework.boot:spring-boot-starter-actuator')
// compile('org.springframework.boot:spring-boot-actuator-docs')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.data:spring-data-rest-hal-browser')
compile('org.springframework.boot:spring-boot-starter-web')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
//compileOnly("com.h2database:h2")
compile 'org.springframework.data:spring-data-oracle:1.2.1.RELEASE'
// compile 'org.springframework.metrics:spring-metrics:latest.release'
// compile 'io.prometheus:simpleclient_common:latest.release'
// Libs folder for oracle JBDC
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'lib', include: ['*.jar'])
// https://mvnrepository.com/artifact/joda-time/joda-time
compile group: 'joda-time', name: 'joda-time', version: '2.9.9'
compileOnly "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}"
//annotationProcessor "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}"
//implementation "org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}"
compileOnly('org.projectlombok:lombok')
//annotationProcessor('org.projectlombok:lombok')
//implementation('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
// https://mvnrepository.com/artifact/org.mockito/mockito-core
testCompile "org.mockito:mockito-core:2.+"
/*
// Oracle DB Driver is in private Oracle Maven repo
// I've created the maven settings.xml with hashed password
// but it, "Gradle" dose not read settings.xml so I have set the
//credentials above in the repositories section but now I get other errors
// this fixed the auth errors but now I'm still getting a error
// saying that the files do not exists
compile('com.oracle.jdbc:ojdbc8:12.2.0.1')
*/
// compile('org.jooq:jool:0.9.12')
}
compileJava.dependsOn(processResources)
task removeOut(type: Delete) {
//noinspection GroovyAssignabilityCheck
delete 'out'
}