我有一个Spring Boot项目,它基于
Spring Framework 4.3.7.RELEASE
和Spring Boot 1.5.2.RELEASE
。
我使用Java配置方法。如何将此项目升级到Spring Boot和Spring Framework (Spring Boot 2.x
、Spring Framework 5.x
)的最新版本?我已经查看了this page,但不幸的是它对我没有什么真正的帮助。将很高兴在这方面得到任何进一步的指导。
这是我的build.gradle
文件的样子:
buildscript {
ext {
springBootVersion = '1.5.2.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
version = '0.1.0-alpha.2'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
bootRun.systemProperties = System.properties
springBoot {
executable = true
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('mysql:mysql-connector-java')
compile('org.modelmapper:modelmapper:1.1.0')
compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
testCompile('org.modelmapper:modelmapper:1.1.0')
}
发布于 2017-11-24 20:57:26
升级的第一步是增加spring-boot-starter-parent
的版本。在您使用Gradle的情况下,它将是属性springBootVersion
中的版本。
然而,对于Spring Boot 2,需要注意的是,目前还没有最终版本,因此您必须包含Spring Boot中的里程碑或快照存储库。您可以在这里找到URL:https://docs.spring.io/spring-boot/docs/2.0.0.M4/reference/htmlsingle/#getting-started-first-application-pom,尽管该文档是针对Maven的。
Gradle的正确设置如下所示:
buildscript {
ext {
springBootVersion = '2.0.0.M6'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
https://stackoverflow.com/questions/47472610
复制相似问题