1.问题

最近研究Gradle进行项目构建,记录下第一次使用Gradle遇到的兼容性问题

 采取idea里创建springboot项目的方式创建gradle project,springboot版本2.7.2,idea为2019.2.4版本,创建项目后自动进行Gradle配置后遇到这个报错信息.


FAILURE: Build failed with an exception.

* Where:
Build file 'D:\work\gradle-demo1\build.gradle' line: 2

* What went wrong:
An exception occurred applying plugin request [id: 'org.springframework.boot', version: '2.7.2']
> Failed to apply plugin [id 'org.springframework.boot']
   > Spring Boot plugin requires Gradle 6.8.x, 6.9.x, or 7.x. The current version is Gradle 5.2.1

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

* Get more help at https://help.gradle.org

 

将gradle版本更换到7.5后又报下面的错误信息.试了下重新安装gradle的依赖但仍未解决

Unable to find method 'org.codehaus.groovy.runtime.StringGroovyMethods.capitalize(Ljava/lang/String;)Ljava/lang/String;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

后面发现自己2019.2.4版的idea自带的plugin里gradle版本是5.2.1,跟7.5相差了2个大版本.猜想是不是idea版本过低,于是换成2021.3版的idea,重新创建gradle项目,顺利运行.

 

2.总结

1.Gradle版本和Springboot版本需要兼容,参考springboot官方.

 

2.Gradle和idea版本也要兼容,暂时不清楚版本兼容对应关系

可以查看idea里plugins\gradle\lib里gradle的jar包版本作参考,如果想用gradle来构建springboot项目,还是建议idea升级换代到新版本.

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐