展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

gradle常见问题与错误

  • 错误1:gradle项目控制台输出为乱码
# 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302
# 在gradle-wrapper.properties 添加以下内容
org.gradle.jvmargs=-Dfile.encoding=UTF-8
# 点击help->edit custom vm options 添加以下内容
-Dfile.encoding=UTF-8
# file -> settings -> Build Tools —> Gradle -> 把build and run using 和Run tests using 都改为Intelij IDEA
  • 问题1
Q1:新建一个gradle项目,将其作为父工程,父工程中有src目录;在此之上新建子模块时使用spring boot快速构建,那么该子模块不会与父工程关联
A1:新建父工程或子模块都应该使用gradle构建

  • 问题2
Q2:编译时报错:Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is
A2:尝试修改为可以用的版本 --> 参考:https://blog.csdn.net/Rmbzz/article/details/106692188

  • 问题3
Q3:编译时报错:A problem occurred evaluating root project ‘xxxxx‘.
A3:错误原因如下:
例如在父工程的build.gradle中有如下配置
// 二进制插件
plugins {
id 'java'
id 'org.springframework.boot' version '2.4.0'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
// 子项目的通用配置
subprojects {
// 使用插件
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
}
# 如果将plugins中的id 'org.springframework.boot' version '2.4.0'注释了,那么subprojects中的apply plugin: 'org.springframework.boot'就会找不到,导致报如上的错误
  • 问题4
Q4:编译时报错:Circular dependency between the following tasks.
A4:相互依赖导致的报错
例如在父工程中引入了公共模块编译后的包
dependencies {
implementation project(':common-api')
}
而公共模块作为子模块又依赖于父工程
解决方案就是让其中一方不依赖于另一方
参考:https://blog.csdn.net/qq_32136827/article/details/109847008
  • 问题5
Q5:编译时报错:[ERROR]all buildscript {} blocks must appear before any plugins {} blocks in the script
A5buildscript块必须出现在plugins块之前
参考:https://blog.csdn.net/qq_24944303/article/details/106350033
  • 问题6
Q6:gradle中某些依赖无法导入,呈灰色显示:No candidates found for method call mavenBom.
解决方案:本地安装的gradle版本确保与idea中的gradle版本一致

  • gardle运行main方法报错:finshed with non-zero wxit value 1

posted @   DogLeftover  阅读(1701)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
历史上的今天:
2021-07-22 ubuntu入门
点击右上角即可分享
微信分享提示