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
A5:buildscript块必须出现在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


解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...