本文介绍了Spring Boot 1.3.3不是用gradle 3.0构建的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Spring boot 1.3.3项目不是用gradle 3构建的,因为spring boot gradle插件是为gradle 2而建。因此,只能用gradle 2来构建这个项目,而不能用gradle 3来构建。

b启动Gradle守护进程,1个不兼容,1个停止守护进程无法重用,请使用--status获取详细信息
不推荐使用Task.leftShift(Closure)方法,并计划在Gradle 5.0中移除它。请改用Task.doLast(Action)。
at build_2yz3q0eod1vuhee49o6tow8db.run(C:\Users\\\
m_su\Projects\provisioning\mobipm\build.gradle:23)

失败:构建失败,出现异常。

*其中:
构建文件'C:\ Users \ nm_su \Projects\provisioning\mobipm\build.gradle'行:26

*出了什么问题:
评估根项目mobipm时出现问题。
>无法应用插件[class'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
>无法创建类型为'DependencyManagementReportTask'的任务。

*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。

构建失败

总时间:11.67秒

$ gradle --version

------ -------------------------------------------------- ----
Gradle 3.2.1
---------------------------------- --------------------------

生成时间:2016-11-22 15:19:54 UTC
版本:83b485b914fd4f335ad0e66af9d14aad458d2cc5

Groovy:2.4.7
Ant:Apache Ant(TM)版本1.9.6 2015年6月29日编译
JVM:1.8.0_111(Oracle Corporation 25.111-b14)
操作系统:Windows 10 10.0 amd64

现在让我们用gradle 2.14 .1,

  $ gradle build 
:framework:compileJava
:framework:processResources UP-TO- DATE
:framework:classes
:framework:jar
:compileJava
:processResources UP-TO-DATE
:classes
:findMainClass
:jar
:bootRepackage
:汇编
:compileTestJava
:processTestResources UP-TO-DATE $ b $:testClass es
:test
:check
:build
:framework:findMainClass
:framework:bootRepackage
:framework:assemble
:framework: compileTestJava
:framework:processTestResources UP-TO-DATE
:framework:testClasses
:framework:test
:framework:check
:framework:build

建立成功

总时间:31.104秒

$ gradle --version

----------- --------------------------------------------------
Gradle 2.14.1
-------------------------------------- ----------------------

生成时间:2016-07-18 06:38:37 UTC
版本: d9e2113d9fb05a5caabba61798bdb8dfdca83719

Groovy:2.4.4
Ant:Apache Ant(TM)1.9.6版于2015年6月29日编译
JVM:1.8.0_111(Oracle Corporation 25.111-b14)
OS:Windows 10 10.0 amd64

如果您使用eclipse插件Buildship Gradle Integration 2.0 ,然后导入Spring引导1.3.3项目中,明确选择gradle的旧版本如下 =nofollow noreferrer>

解决方案

确保build.gradle具有如下的包装器任务:

 任务包装器(类型:包装器){
gradleVersion ='2.9'
}

从命令行运行gradle wrapper,它会为unix和windows创建gradle包装。将它们推送到源代码管理,以便没有手动步骤。

  gradle包装器
git添加gradlew gradlew.bat gradle
git commit -m添加gradle包装到git repo
git push



  $ ./gradlew build 
:framework:compileJava
:framework:processResources
:framework:classes
:framework:jar
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:汇编
:compileTestJava
:processTestResources UP-TO-DATE $ b $:testClasses
:test
:check
:build
:framework:findMainClass
:framework:bootRepackage
:framework:assemble
:framework:compileTestJava
:framework:processTestResources UP-TO-DATE
:framework:testClasses
:framework:test
:framework:check
:framework:build

建立成功

总时间:42.712秒

感谢吸血鬼的回应...


Thought of sharing below info as i spent couple of hours finding this:

Spring boot 1.3.3 project is not building with gradle 3 as spring boot gradle plugin is built for gradle 2. Hence, build this project only with gradle 2 but not with gradle 3.

$ gradle build
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_2yz3q0eod1vuhee49o6tow8db.run(C:\Users\nm_su\Projects\provisioning\mobipm\build.gradle:23)

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\nm_su\Projects\provisioning\mobipm\build.gradle' line: 26

* What went wrong:
A problem occurred evaluating root project 'mobipm'.
> Failed to apply plugin [class 'io.spring.gradle.dependencymanagement.DependencyManagementPlugin']
   > Could not create task of type 'DependencyManagementReportTask'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 11.67 secs

$ gradle --version

------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------

Build time:   2016-11-22 15:19:54 UTC
Revision:     83b485b914fd4f335ad0e66af9d14aad458d2cc5

Groovy:       2.4.7
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_111 (Oracle Corporation 25.111-b14)
OS:           Windows 10 10.0 amd64

Now lets try building with gradle 2.14.1,

$ gradle build
:framework:compileJava
:framework:processResources UP-TO-DATE
:framework:classes
:framework:jar
:compileJava
:processResources UP-TO-DATE
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:framework:findMainClass
:framework:bootRepackage
:framework:assemble
:framework:compileTestJava
:framework:processTestResources UP-TO-DATE
:framework:testClasses
:framework:test
:framework:check
:framework:build

BUILD SUCCESSFUL

Total time: 31.104 secs

$ gradle --version

------------------------------------------------------------
Gradle 2.14.1
------------------------------------------------------------

Build time:   2016-07-18 06:38:37 UTC
Revision:     d9e2113d9fb05a5caabba61798bdb8dfdca83719

Groovy:       2.4.4
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_111 (Oracle Corporation 25.111-b14)
OS:           Windows 10 10.0 amd64

If you are using eclipse plugin "Buildship Gradle Integration 2.0", then while importing the Spring boot 1.3.3 project, explicitly select the olderversion of gradle as below

解决方案

Make sure that the build.gradle has the "wrapper" task as below:

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

Run the "gradle wrapper" from the command line, it would create the gradle wrappers for unix and windows. Push them to source control so that,there are no manual steps.

gradle wrapper
git add gradlew gradlew.bat gradle
git commit -m "Adding gradle wrapper to git repo"
git push

So all the future builds can be using gradlew

$ ./gradlew build
:framework:compileJava
:framework:processResources
:framework:classes
:framework:jar
:compileJava
:processResources
:classes
:findMainClass
:jar
:bootRepackage
:assemble
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test
:check
:build
:framework:findMainClass
:framework:bootRepackage
:framework:assemble
:framework:compileTestJava
:framework:processTestResources UP-TO-DATE
:framework:testClasses
:framework:test
:framework:check
:framework:build

BUILD SUCCESSFUL

Total time: 42.712 secs

Thanks to answer from Vampire...

这篇关于Spring Boot 1.3.3不是用gradle 3.0构建的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 09:00