Spring启动gradle插件无法正常工作

时间:2016-07-16 15:18:47

标签: java plugins gradle spring-boot

我有一个问题,我的春季启动项目运行良好,但我不能运行gradle构建,调试或建立战争或任何东西。

我在错误报告中得到以下stacktrace:



org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'thetenticle.api'.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
	at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
	at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:466)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:77)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
	at org.gradle.api.internal.Actions$CompositeAction.execute(Actions.java:78)
	at org.gradle.api.internal.Actions$TransformingActionAdapter.execute(Actions.java:130)
	at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:442)
	at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:437)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:40)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
	at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:63)
	at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:44)
	at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:98)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
	at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: java.lang.NoSuchMethodError: org.gradle.api.tasks.TaskContainer.create(Ljava/lang/String;Ljava/lang/Class;)Lorg/gradle/api/Task;
	at org.springframework.boot.gradle.repackage.RepackagePluginFeatures.addRepackageTask(RepackagePluginFeatures.java:61)
	at org.springframework.boot.gradle.repackage.RepackagePluginFeatures.apply(RepackagePluginFeatures.java:56)
	at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:45)
	at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:38)
	at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.providePlugin(DefaultProjectsPluginContainer.java:107)
	at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.addPluginInternal(DefaultProjectsPluginContainer.java:71)
	at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
	at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
	at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:854)
	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_29m6desjd64mvpujgjg1iamv4j.run(/home/glagnar/workspace/api.thetenticle/build.gradle:16)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
	... 55 more




我的gradle.build文件如下所示:



buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'


repositories {
    mavenCentral()
    maven { url 'http://maven.springframework.org/release' }
    maven { url 'http://maven.springframework.org/milestone' }
    maven { url 'http://maven.springframework.org/snapshot' }
    maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
    maven { url 'http://download.java.net/maven/2' }
}

jar {
    baseName = 'thetenticle.api'
    version =  '0.1.0'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8


dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    //compile("org.springframework.boot:spring-boot-starter-jdbc")

    compile("mysql:mysql-connector-java:5.1.34")

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

    compile("com.h2database:h2")
    compile('org.mockito:mockito-core:1.9.5')
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.3.5'
}




我搜索了很多,但没有找到好的解决方案。

1 个答案:

答案 0 :(得分:1)

您使用的Gradle版本不符合Spring Boot 1.3.5 requirements

  

Spring Boot与Gradle 1.12或更高版本兼容

我建议使用2.14,在撰写本文时,它是最新的稳定版本。