gradle学习及问题

一、下载安装

参考:https://blog.csdn.net/chentian114/article/details/123344839

1、下载Gradle并解压

安装包:gradle-6.7-bin.zip

可以在idea的安装目录查看自己适配的版本
路径:D:\IDEA2021.3\plugins\gradle\lib

下载地址:https://services.gradle.org/distributions/
解压到本地文件夹

2、配置环境变量

1.配置环境变量 GRADLE_HOME,对应Gradle的安装目录。
在这里插入图片描述

2.配置环境变量 GRADLE_USER_HOME,对应Gradle本地仓库或工作空间目录(自已创建的指定目录)。
在这里插入图片描述
3.在Path中添加Gradle
%GRADLE_HOME%\bin;
在这里插入图片描述
4.测试
win+R,输入cmd ,输入 gradle -v
在这里插入图片描述
gradle 安装成功。

3、配置Gradle国内仓库

在gradle目录D:\ProgramDevs\gradle-6.7\init.d,添加一个文件 init.gradle ,添加以下内容

allprojects {
    repositories {
        maven { url 'file:///D:/ProgramDevs/gradleRepo'}
        mavenLocal()
        maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }
        mavenCentral()
    }

    buildscript { 
        repositories { 
            maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }
            maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
        }
    }
}

maven { url 'file://D:/ProgramDevs/gradleRepo'} 配置的是Gradle本地仓库或工作目录的地址,对应GRADLE_USER_HOME

4、IDEA 配置Gradle

在这里插入图片描述
gradle build 构建项目成功。
在这里插入图片描述

二、遇到的问题

1、Could not resolve org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3.

Gradle同步报错信息
参考:https://blog.csdn.net/weixin_43365786/article/details/130879812

A problem occurred configuring root project 'simple_language_plugin'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3.
     Required by:
         project : > org.jetbrains.intellij:org.jetbrains.intellij.gradle.plugin:1.13.3
      > No matching variant of org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.1.1' but:
          - Variant 'apiElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')
          - Variant 'javadocElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')
          - Variant 'runtimeElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')
          - Variant 'sourcesElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.13.3 declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')
          - Variant 'testFixturesApiElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin-test-fixtures:1.13.3 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.1')
          - Variant 'testFixturesRuntimeElements' capability org.jetbrains.intellij.plugins:gradle-intellij-plugin-test-fixtures:1.13.3 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.1.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.

原因分析
1、Gradle版本与org.jetbrains.intellij.plugins:gradle-intellij-plugin版本不匹配
2、Java编译环境版本不匹配

针对第1个原因
Gradle版本与org.jetbrains.intellij.plugins:gradle-intellij-plugin版本不匹配

  1. 进入项目目录gradle/wrapper/gradle-wrapper.properties
  2. 查看distributionUrl所填写的Gradle版本号
  3. 打开gradle-intellij-plugin发布版本记录(点击访问)
  4. 查看对应org.jetbrains.intellij.plugins:gradle-intellij-plugin版本是否兼容项目对应的Gradle版本,Gradle发布版本记录(点击访问)
  5. 若不兼容,则调整项目Gradle版本为插件对应支持的Gradle版本,或调整插件为兼容项目当前Gradle版本的版本号
  6. 保存配置后,再次执行Gradle同步操作,等待项目indexing完毕即可

针对第2个原因
Java编译环境版本不匹配

  1. 打开IDEA的File-Settings-Build, Execution, Deployment-Build Tools-Gradle菜单
  2. 查看Gradle Projects面板下的Gradle-Gradle JVM版本
  3. 如上述错误例子,描述意为当前编译组件与Java 11兼容,使用与Java 8兼容,那么就是需要一个Java 11的编译环境
  4. 因此,我们调整Gradle-Gradle JVM版本为Java 11版本的JDK即可
  5. 保存设置后,再次执行Gradle同步操作,等待项目indexing完毕即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/802216.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

idea中使用maven

默认情况下,idea会自动下载并安装maven,这不便于我们管理。 最好是自行下载maven,然后在idea中指定maven的文件夹路径

VMware安装CentOS 7

在虚拟机中安装无论是Windows还是Linux其实都差不多,主要还是需要熟悉VMware的使用,多新增几次就熟悉了,可以反复删除再新增去练习… 如下是安装CentOS 7 安装过程: VMare Workstation 16 PRO 中安装CentOS 7 CentOS 7 下载推荐…

工业三防平板可优化工厂流程管理

在当今高度自动化和数字化的工业生产环境中,工业三防平板正逐渐成为优化工厂流程管理的关键工具。其强大的功能和卓越的性能,为工厂带来了更高的效率、更低的成本以及更出色的质量控制。 工业三防平板,顾名思义,具备防水、防尘、防…

在AWS创建一台Windows主机并登录

正文共:1111 字 21 图,预估阅读时间:1 分钟 因为之前微软云Azure免费,我们还做了简单的测试(白嫖党618福利!来Azure领200美刀!外加云主机免费用一年!);并且通…

linux中.a和.so库文件

区别 在Linux系统中,.a和.so文件是两种常见的库文件格式,它们在功能、使用方式及编译链接过程中存在显著的区别。以下是这两类文件的具体区别: 1. 文件类型与功能 .a文件: 类型:归档库文件,也称为静态库。…

46 mysql 客户端拿不到具体的错误信息

前言 这是最近碰到的一个问题 同样的一个 环境的问题, 在正常的 mysql 环境会返回 具体的错误信息, 然后 在我的另外一个环境里面 只能返回一些 unknown error 之类的 十分抽象的环境 然后 我们这里 来看一下 具体的情况 我们这里从 错误的环境 往前推导 来查看 并解决这个…

微软研究人员为电子表格应用开发了专用人工智能LLM

微软的 Copilot 生成式人工智能助手现已成为该公司许多软件应用程序的一部分。其中包括 Excel 电子表格应用程序,用户可以在其中输入文本提示来帮助处理某些选项。微软的一组研究人员一直在研究一种新的人工智能大型语言模型,这种模型是专门为 Excel、Go…

MongoDB常用命令大全

文章目录 一、MongoDB简介二、服务启动停止备份三、数据库相关四、集合操作五、文档操作六、其他常用命令 一、MongoDB简介 MongoDB是一款流行的NoSQL数据库,以其灵活的文档模型、高可用性、易于扩展等特性而受到广泛关注。 MongoDB 是由C语言编写的,是…

<数据集>UA-DETRAC车辆识别数据集<目标检测>

数据集格式:VOCYOLO格式 图片数量:20500张 标注数量(xml文件个数):20500 标注数量(txt文件个数):20500 标注类别数:4 标注类别名称:[car, van, others, bus] 序号类别名称图片数框数1car201871259342…

Excel 学习手册 - 精进版(包括各类复杂函数及其嵌套使用)

作为程序员从未想过要去精进一下 Excel 办公软件的使用方法,以前用到某功能都是直接百度,最近这两天跟着哔哩哔哩上的戴戴戴师兄把 Excel 由里到外学了一遍,收获良多。程序员要想掌握这些内容可以说是手拿把掐,对后续 Excel 的运用…

在 Linux 系统中安装MySQL 8.x(Ubuntu和CentOS)

文章目录 0. 前言1. 查看 Linux 的发行版本2. 在 Ubuntu 中安装MySQL 8.x2.1 更新包索引2.1.1 更改 Ubuntu 的镜像源2.1.2 更新软件包、升级软件包(耗时可能较长)2.1.3 可能遇到的问题 2.2 安装MySQL2.3 安全配置2.3.1 密码安全级别2.3.2 删除匿名用户2.…

【算法笔记自学】第 9 章 提高篇(3)——数据结构专题(2)

9.1树与二叉树 #include <cstdio>int main() {int n, m;scanf("%d%d", &n, &m);printf(n m 1 ? "Yes" : "No");return 0; } 9.2二叉树的遍历 #include <cstdio> #include <vector> using namespace std;const int…

NLP入门——RNN、LSTM模型的搭建、训练与预测

在卷积语言模型建模时&#xff0c;我们选取上下文长度ctx_len进行训练&#xff0c;预测时选取句子的最后ctx_len个分词做预测&#xff0c;这样句子的前0~seql-1-ctx_len个词对于预测没有任何帮助&#xff0c;这对于语言处理来说显然是不利的。 在词袋语言模型建模时&#xff0c…

C语言 底层逻辑详细阐述指针(一)万字讲解 #指针是什么? #指针和指针类型 #指针的解引用 #野指针 #指针的运算 #指针和数组 #二级指针 #指针数组

文章目录 前言 序1&#xff1a;什么是内存&#xff1f; 序2&#xff1a;地址是怎么产生的&#xff1f; 一、指针是什么 1、指针变量的创建及其意义&#xff1a; 2、指针变量的大小 二、指针的解引用 三、指针类型存在的意义 四、野指针 1、什么是野指针 2、野指针的成因 a、指…

【HarmonyOS】关于鸿蒙消息推送的心得体会 (一)

【HarmonyOS】关于鸿蒙消息推送的心得体会&#xff08;一&#xff09; 前言 这几天调研了鸿蒙消息推送的实现方式&#xff0c;形成了开发设计方案&#xff0c;颇有体会&#xff0c;与各位分享。 虽然没做之前觉得很简单的小功能&#xff0c;貌似只需要和华为服务器通信&…

玩转HarmonyOS NEXT之AppStorage应用全局UI状态存储

概述 AppStorage是应用全局的UI状态存储&#xff0c;是和应用的进程绑定的&#xff0c;由UI框架在应用程序启动时创建&#xff0c;为应用程序UI状态属性提供中央存储。 AppStorage是在应用启动的时候会被创建的单例。它的目的是为了提供应用状态数据的中心存储&#xff0c;这…

【HarmonyOS学习】Calendar Kit日历管理

简介 Calendar Kit提供日历与日程管理能力&#xff0c;包括日历的获取和日程的创建能力。 Calendar Kit为用户提供了一系列接口来获取日历账户&#xff0c;并使用特定的接口向日历账户中写入日程。 如果写入的日程带有提醒时间则系统会在时间到达时向用户发送提醒。 约束点…

Linux编程(通信协议---udp)

UDP&#xff08;用户数据报协议&#xff09;是一种无连接的网络协议&#xff0c;主要用于快速传输数据。以下是UDP协议的一些主要特点&#xff1a; 1. **无连接**&#xff1a;UDP是无连接的协议&#xff0c;这意味着在数据传输之前不需要建立连接。每个UDP数据包都是独立的&am…

remote: ERROR: commit b81ea84: missing Change-Id in message footer

首次拉取代码后,在本地已经编辑添加了代码并且想要提交到远端仓库 git add . git commit 当commit之后想要pull的时候报错了 git pull 执行到git pull 时出现这个问题,这是由于Change-Id没了,提示: ! [remote rejected] HEAD -> refs/for/master (commit b81ea84: mis…

git回退分支版本git reset --hard HEAD

git回退分支版本git reset --hard HEAD git reset --hard HEAD 上面命令清除本地所有修改&#xff0c;与下面相似&#xff1a; git reset --hard origin/master 等同于&#xff1a; git reset --hard HEAD~0 说明&#xff1a; HEAD 当前版本 HEAD^ 上一个版本 HEAD^^ 上上…