Spring Boot get property of a package in Gradle

前端 未结 1 592
孤独总比滥情好
孤独总比滥情好 2021-01-02 06:04

Im trying to convert my project from Maven build to Gradle. The project currently uses Spring Boot.

In my current maven config, I have

    

        
相关标签:
1条回答
  • 2021-01-02 06:58

    You can use the dependency management plugin to import Spring Boot's bom and get access to the properties that it specifies.

    Here's you original build.gradle file with the necessary changes:

    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")
    }
    

    Spring Boot 1.3 will start using the dependency management plugin by default when it'll apply the plugin and import the bom for you.

    0 讨论(0)
提交回复
热议问题