gradle spring boot force依赖

时间:2017-10-29 12:11:52

标签: gradle

我正在使用spring boot gradle插件2.0.0.M3,我希望在最后一个jar中包含spring-data-elasticsearch:3.0.0.RC2

以下是我的build.gradle

buildscript {
    ext {
        springBootVersion = '2.0.0.M3'
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
    id "io.spring.dependency-management" version "1.0.3.RELEASE"
}

apply plugin: 'org.springframework.boot'
apply plugin: 'maven-publish'
apply plugin: 'java'

dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Finchley.M2'
    }
}

group='mygroup'
version='1.0.0'


configurations.all {
    exclude group: 'javax.servlet.jsp', module: 'jsp-api'
    exclude group: 'org.mortbay.jetty'

    resolutionStrategy {
        force("org.springframework.data:spring-data-elasticsearch:3.0.0.RC2")
    }

}

但是力量解决方案无效。而不是spring-data-elasticsearch-3.0.0.RC2,spring-data-elasticsearch-3.0.0.M4被拉。

以下是依赖详情

org.springframework.data:spring-data-elasticsearch:3.0.0.RC2 - > 3.0.0.M4

强制解析在Spring启动时不起作用吗?

1 个答案:

答案 0 :(得分:1)

如果以通常的方式提到依赖

,它就有效
configurations.all {

    resolutionStrategy {
        force("org.springframework.data:spring-data-elasticsearch:3.0.0.RC2")
    }

}

dependencies {

    compile("org.springframework.boot:spring-boot-starter-data-jpa")

    compile "org.springframework.data:spring-data-elasticsearch:3.0.0.RC2"
}