如何使用 Spring IO Platform BOM 和 Spring Boot with Gradle?
How do I use Spring IO Platform BOM and Spring Boot with Gradle?
所以这个 build.gradle
似乎工作正常
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'entity-api'
version = '0.1.0-SNAPSHOT'
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
compile('org.springframework.data:spring-data-commons')
testCompile('junit:junit')
testCompile('org.mockito:mockito-core')
testCompile('nl.jqno.equalsverifier:equalsverifier:1.7.5')
}
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE')
classpath( 'io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE')
}
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'entity-api'
version = '0.1.0-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.3.RELEASE'
}
}
dependencies {
compile('org.springframework.data:spring-data-commons')
testCompile('junit:junit')
testCompile('org.mockito:mockito-core')
testCompile('nl.jqno.equalsverifier:equalsverifier:1.7.5')
}
但是当我这样做时 gradle 输出以下内容?值得一提的是,maven 的自动转换对我不起作用,所以我正在学习如何手动转换。我如何修复我的 gradle 构建以使用 spring 平台 bom?
gradle build --stacktrace slave-vi
FAILURE: Build failed with an exception.
* Where:
Build file '/home/xenoterracide/IdeaProjects/entity-api/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating root project 'entity-api'.
> org/gradle/mvn3/org/apache/maven/model/building/ModelBuildingException
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'entity-api'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.run(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:153)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:491)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:89)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:126)
at org.gradle.internal.Factories.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:123)
at org.gradle.initialization.DefaultGradleLauncher.access0(DefaultGradleLauncher.java:33)
at org.gradle.initialization.DefaultGradleLauncher.create(DefaultGradleLauncher.java:100)
at org.gradle.initialization.DefaultGradleLauncher.create(DefaultGradleLauncher.java:94)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:94)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.NoClassDefFoundError: org/gradle/mvn3/org/apache/maven/model/building/ModelBuildingException
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.class$(DependencyManagementPlugin.groovy)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.$get$$class$io$spring$gradle$dependencymanagement$maven$EffectiveModelBuilder(DependencyManagementPlugin.groovy)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy:79)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access0(DefaultObjectConfigurationAction.java:35)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.run(DefaultObjectConfigurationAction.java:79)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:135)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply[=15=].callCurrent(Unknown Source)
at build_99h9uwt24qv8u37y4ugf5nxl6.run(/home/xenoterracide/IdeaProjects/entity-api/build.gradle:13)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 47 more
Caused by: java.lang.ClassNotFoundException: org.gradle.mvn3.org.apache.maven.model.building.ModelBuildingException
... 65 more
BUILD FAILED
Total time: 11.328 secs
Gradle 2.5 中有一个重大的 API 变化影响了依赖管理插件。升级到最新版本 0.5。3.RELEASE,解决了这个问题。
我已经打开 an issue 来更新平台的文档。感谢您提请我注意这个问题。
所以这个 build.gradle
似乎工作正常
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'entity-api'
version = '0.1.0-SNAPSHOT'
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
compile('org.springframework.data:spring-data-commons')
testCompile('junit:junit')
testCompile('org.mockito:mockito-core')
testCompile('nl.jqno.equalsverifier:equalsverifier:1.7.5')
}
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE')
classpath( 'io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE')
}
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'entity-api'
version = '0.1.0-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.3.RELEASE'
}
}
dependencies {
compile('org.springframework.data:spring-data-commons')
testCompile('junit:junit')
testCompile('org.mockito:mockito-core')
testCompile('nl.jqno.equalsverifier:equalsverifier:1.7.5')
}
但是当我这样做时 gradle 输出以下内容?值得一提的是,maven 的自动转换对我不起作用,所以我正在学习如何手动转换。我如何修复我的 gradle 构建以使用 spring 平台 bom?
gradle build --stacktrace slave-vi
FAILURE: Build failed with an exception.
* Where:
Build file '/home/xenoterracide/IdeaProjects/entity-api/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating root project 'entity-api'.
> org/gradle/mvn3/org/apache/maven/model/building/ModelBuildingException
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'entity-api'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.run(DefaultScriptPluginFactory.java:148)
at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:153)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:491)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:89)
at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:126)
at org.gradle.internal.Factories.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:123)
at org.gradle.initialization.DefaultGradleLauncher.access0(DefaultGradleLauncher.java:33)
at org.gradle.initialization.DefaultGradleLauncher.create(DefaultGradleLauncher.java:100)
at org.gradle.initialization.DefaultGradleLauncher.create(DefaultGradleLauncher.java:94)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:94)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.NoClassDefFoundError: org/gradle/mvn3/org/apache/maven/model/building/ModelBuildingException
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.class$(DependencyManagementPlugin.groovy)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.$get$$class$io$spring$gradle$dependencymanagement$maven$EffectiveModelBuilder(DependencyManagementPlugin.groovy)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy:79)
at io.spring.gradle.dependencymanagement.DependencyManagementPlugin.apply(DependencyManagementPlugin.groovy)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access0(DefaultObjectConfigurationAction.java:35)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.run(DefaultObjectConfigurationAction.java:79)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:135)
at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:46)
at org.gradle.api.plugins.PluginAware$apply.call(Unknown Source)
at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
at org.gradle.api.Script$apply[=15=].callCurrent(Unknown Source)
at build_99h9uwt24qv8u37y4ugf5nxl6.run(/home/xenoterracide/IdeaProjects/entity-api/build.gradle:13)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 47 more
Caused by: java.lang.ClassNotFoundException: org.gradle.mvn3.org.apache.maven.model.building.ModelBuildingException
... 65 more
BUILD FAILED
Total time: 11.328 secs
Gradle 2.5 中有一个重大的 API 变化影响了依赖管理插件。升级到最新版本 0.5。3.RELEASE,解决了这个问题。
我已经打开 an issue 来更新平台的文档。感谢您提请我注意这个问题。