gpt4 book ai didi

gradle - Spring Boot 1.3.3不使用Gradle 3.0构建

转载 作者:行者123 更新时间:2023-12-03 05:59:23 26 4
gpt4 key购买 nike

我花了几个小时发现以下信息,然后想到了在信息下方共享:

Spring Boot 1.3.3项目不是使用gradle 3构建的,因为spring boot gradle插件是为gradle 2构建的。因此,仅使用gradle 2而不是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

现在让我们尝试使用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

如果您使用的是eclipse插件“Buildship Gradle Integration 2.0”,则在导入Spring boot 1.3.3项目时,显式选择gradle的旧版本,如下所示

enter image description here

最佳答案

确保build.gradle具有“包装器”任务,如下所示:

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

从命令行运行“gradle wrapper”,它将为unix和windows创建gradle包装器。将它们推送到源代码管理,因此没有手动步骤。
gradle wrapper
git add gradlew gradlew.bat gradle
git commit -m "Adding gradle wrapper to git repo"
git push

因此,所有将来的构建都可以使用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

感谢吸血鬼的回答...

关于gradle - Spring Boot 1.3.3不使用Gradle 3.0构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42675234/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com