java 未能应用插件 [id 'spring-boot']
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33346449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to apply plugin [id 'spring-boot']
提问by A B
I am trying to use Spring boot in my gradle project. But when I try to clean build
, it gives the following error (only relevant stacktrace):
我正在尝试在我的 gradle 项目中使用 Spring boot。但是当我尝试时clean build
,它给出了以下错误(仅相关的堆栈跟踪):
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'spring-boot']
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:117)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access0(DefaultObjectConfigurationAction.java:36)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.run(DefaultObjectConfigurationAction.java:80)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:131)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:37)
at org.gradle.api.Project$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply.callCurrent(Unknown Source)
at build_2o7juvjo3110jmss6k1iqcfrir.run(/Users/AlmasBarday/bos-api/build.gradle:13)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
... 57 more
Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'spring-boot' not found.
at org.gradle.api.internal.plugins.DefaultPluginRegistry.getTypeForId(DefaultPluginRegistry.java:91)
at org.gradle.api.internal.plugins.DefaultPluginContainer.getTypeForId(DefaultPluginContainer.java:183)
at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:103)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:115)
My build.gradle has the following:
我的 build.gradle 有以下内容:
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'spring-boot'
dependencies {
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'net.sourceforge.jexcelapi:jxl:2.6.12'
compile 'com.qas:proweb:1.0.0'
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"
testCompile 'junit:junit:4.11'
}
I searched the internet and tried solutions posted to similar problems, but nothing seems to work. Also, I am able to build another gradle-springboot project without any problems.
我在互联网上搜索并尝试了针对类似问题发布的解决方案,但似乎没有任何效果。另外,我可以毫无问题地构建另一个 gradle-springboot 项目。
Any help appreciated.
任何帮助表示赞赏。
采纳答案by Stanislav
You've forgot to configure you buildscript, by adding it's dependencies part. You can do it, by addin this to your build.script:
您忘记了通过添加它的依赖项部分来配置您的构建脚本。您可以通过将其添加到您的 build.script 中来做到这一点:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}
Here you're configuring your buildscript dependencies, to make it possible for Gradle to apply the plugin. But that does not mean, that you can delete dependency for you sources. They are still use to be there, like you already have:
在这里,您正在配置 buildscript 依赖项,以使 Gradle 可以应用该插件。但这并不意味着您可以删除源的依赖项。他们仍然习惯在那里,就像你已经拥有的一样:
dependencies {
...
compile "org.springframework:spring-beans:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework.boot:spring-boot-starter-web:1.2.7.RELEASE"
}
回答by jian
plugins { id "org.springframework.boot" version "2.0.1.RELEASE" }
The above script should also be added to build.gradle
at the top level to make it work.
上面的脚本也应该添加到build.gradle
顶层以使其工作。