排除依赖项

时间:2018-04-12 08:47:58

标签: gradle

我想从依赖项中排除依赖项:

dependencies {
...
    implementation "org.springframework.security:spring-security-web:$springSecurityVersion" {

        exclude "org.springframework:spring-core:$springSecurityVersion"
        exclude "org.springframework:spring-beans:$springSecurityVersion"
        exclude "org.springframework:spring-context:$springSecurityVersion"
        exclude "org.springframework:spring-web:$springSecurityVersion"
    }
...
}

我通过更改语法糖尝试了几个选项但是徒劳无功。

更新了例外

org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-4.1-bin.zip'.
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:51)
    at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
    at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
    at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsume
...

除了我认为可能有用的另一行之外还有

  

无法找到方法   org.springframework.security:spring-security-web:5.0.4.RELEASE()for   参数   [build_8wp04892dra2g2ruliafngaad $ _run_closure3 $ _closure5 @ 28d49bbc] on   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler类型的对象。

1 个答案:

答案 0 :(得分:0)

您是否尝试过此语法,但未指定版本:

implementation ("org.springframework.security:spring-security-web:$springSecurityVersion") {
    exclude group: 'org.springframework', module: 'spring-core'
    exclude group: 'org.springframework', module: 'spring-beans'
    exclude group: 'org.springframework', module: 'spring-context'
    exclude group: 'org.springframework', module: 'spring-web'
}

编辑:删除主目录中的.gradle目录,然后重试

edit2:答案已修复,感谢op的评论