rak*_*pan 10 java gradle spring-boot
我试图将我的项目从Maven构建转换为Gradle.该项目目前使用Spring Boot.
在我目前的maven配置中,我有
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>${jackson.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中,jackson.version属性来自Spring Boot pom.现在,在Gradle中,我正在使用Spring Boot插件,我试图使用下面的代码片段.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE")
}}
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'java'
dependencies {
compile("com.fasterxml.jackson.datatype:jackson-datatype-hibernate4")
}
Run Code Online (Sandbox Code Playgroud)
在上面,我期待spring Boot插件插入jackson-hibernate4模块的版本.但是,这不会发生
有关如何实现这一点的任何想法?我的目的是在整个项目中使用相同版本的jackson构建.
谢谢!
您可以使用依赖关系管理插件导入Spring Boot的bom并访问它指定的属性.
这是您原始build.gradle文件的必要更改:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE"
classpath "io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE"
}
}
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'org.springframework.boot:spring-boot-starter-parent:1.2.4.RELEASE'
}
}
ext {
jacksonVersion = dependencyManagement.importedProperties['jackson.version']
}
dependencies {
compile("com.fasterxml.jackson.datatype:jackson-datatype-hibernate4:$jacksonVersion")
}
Run Code Online (Sandbox Code Playgroud)
Spring Boot 1.3默认开始使用依赖管理插件,当它应用插件并为你导入bom时.
| 归档时间: |
|
| 查看次数: |
1411 次 |
| 最近记录: |