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://xiahunao.cn/news/3245709.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

16_网络IPC2-寻址

进程标识 字节序 采用大小模式对数据进行存放的主要区别在于在存放的字节顺序,大端方式将高位存放在低地址,小端方式将高位存放在高地址。 采用大端方式进行数据存放符合人类的正常思维,而采用小端方式进行数据存放利于计算机处理。到目前…

python用selenium网页模拟时xpath无法定位元素解决方法2

有时我们在使用python selenium xpath时,无法定位元素,红字显示no such element。上一篇文章写了1种情况,是包含iframe的,详见https://blog.csdn.net/Sixth5/article/details/140342929。 本篇写第2种情况,就是xpath定…

Linux 线程初步解析

1.线程概念 在一个程序里的一个执行路线就叫做线程(thread)。更准确的定义是:线程是“一个进程内部的控制序列。在linux中,由于线程和进程都具有id,都需要调度等等相似性,因此都可以用PCB来描述和控制,线程含有PCB&am…

人类或是低等生物?

自工业革命以来,人类对自然资源的消耗日益加剧,引发了对未来可持续性的深刻担忧。然而,一项振奋人心的发现为人类提供了新的希望——一颗名为LHS 1140 b的超级地球,它位于距离地球约48光年的鲸鱼座,由詹姆斯韦布空间望…

uniapp字符串转base64,无需导入依赖(多端支持)

使用示例 import { Base64Encode, Base64Decode } from "@/utils/base64.js" base64.js const _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";export const Base64Encode = (text)

Qt Creator的好用的功能

(1)ctrlf: 在当前文档进行查询操作 (2)f3: 找到后,按f3,查找下一个 (3)shiftf3: 查找上一个 右键菜单: (4)f4:在…

使用vcXsrv可视化pcl文件

1、下载vcXsrc程序 2、按下面步骤配置 3、按上面操作后,在运行菜单就能看到它在运行了 4、去wsl中配置,即设置环境变量 vim ~/.bashrc # 设置连接windows的VcXsrv export DISPLAY192.168.1.100:0.0 #(192.168.1.100是我windows的ip&#x…

信创学习笔记(四),信创之数据库DB思维导图

创作不易 只因热爱!! 热衷分享,一起成长! “你的鼓励就是我努力付出的动力” 一. 信创学习回顾 1.信创内容 信创内容思维导图 2.信创之CPU芯片架构 信创之CPU芯片架构思维导图 3.信创之操作系统OS 信创之操作系统OS思维导图 二. 信创之国产数据库DB思维导图 …

LAST_INSERT_ID使用方法-(DM8达梦数据库)

LAST_INSERT_ID使用方法 - DM8达梦数据库 1 示例 11.1 创建表1.2 结果集 2 示例 22.1 创建表2.2 结果集 3 达梦数据库学习使用列表 1 示例 1 1.1 创建表 DROP TABLE AT240715; CREATE TABLE "SYSDBA"."AT240715" ( "ID" INT PRIMARY KEY AUTO_…

Autosar Dcm配置-0x28服务ComControl-基于ETAS软件

文章目录 前言DcmDcmDsdDcmDspBswMBswMModeRequestPortBswMModeConditionBswMLogicalExpressionBswMActionBswMActionListBswMRule总结前言 0x28服务主要用来控制非诊断报文的通讯,一般在刷写预编程过程中,用来禁止APP的通信报文,可以减少总线负载率,提高刷写成功率。本文…

数据结构之线性表表示集合详解与示例(C,C#,C++)

文章目录 基本特征线性表的特点:线性表的表示方法:C、C#和C语言如何实现一个线性表表示集合1. C实现2. C#实现3. C实现 总结 线性表是计算机数据结构中的一个基本概念,它是一种最简单的抽象数据类型。在线性表中,数据元素之间的关…

pip install安装第三方库 error: Microsoft Visual C++ 14.0 or greater is required

原因: 在windows出现此情况的原因是pip安装的库其中部分代码不是python而是使用C等代码编写,我们安装这种类型的库时需要进行编译后安装。 安装Microsoft C Build Tools软件,但这种方式对于很多人来说过于笨重。(不推荐&#xf…

VUE:跨域配置代理服务器

//在vite.config。js中,同插件配置同级进行配置server:{proxy:{"/myrequest":{//代理域名,可自行修改target:"https://m.wzj.com/",//访问服务器的目标域名changeOrigin:true,//允许跨域configure:(proxy,options) > {proxy.on(&…

【Django+Vue3 线上教育平台项目实战】登录功能模块之短信登录与钉钉三方登录

文章目录 前言一、几个关键概念1.HTTP无状态性2.Session机制3.Token认证4.JWT 二、通过手机号验证码登录1.前端短信登录界面2.发送短信接口与短信登录接口3.Vue 设置interceptors拦截器4. 服务端验证采用自定义中间件方式实现5. 操作流程及效果图如下: 三、通过第三…

Flychat:跨越距离的心灵桥梁

在当今这个数字化时代,人们的沟通方式变得越来越多样化,而移动设备的普及更是极大地推动了这一趋势。我们几乎可以随时随地与他人进行交流,分享生活的点滴。然而,在享受这些便捷的同时,我们也时常会遇到一些小困扰——…

Rust 使用 panic! 还是不用 panic!

使用 panic! 还是不用 panic! 那么,该如何决定何时应该 panic! 以及何时应该返回 Result 呢?如果代码 panic,就没有恢复的可能。你可以选择对任何错误场景都调用 panic!,不管是否有可能恢复,不过这样就是你代替调用者…

年化18.9%的创业板趋势策略,使用模块化策略模板重构(代码+数据)

原创文章第590篇,专注“AI量化投资、世界运行的规律、个人成长与财富自由"。 昨天咱们分享的文章:”以交易为生“,基础设施很重要。 传统backtrader写策略的步骤是如下: 1、定义因子,比如动量roc: …

基于LSTM及其变体的回归预测

1 所用模型 代码中用到了以下模型: 1. LSTM(Long Short-Term Memory):长短时记忆网络,是一种特殊的RNN(循环神经网络),能够解决传统RNN在处理长序列时出现的梯度消失或爆炸的问题。L…

华为OD算法题汇总

60、计算网络信号 题目 网络信号经过传递会逐层衰减,且遇到阻隔物无法直接穿透,在此情况下需要计算某个位置的网络信号值。注意:网络信号可以绕过阻隔物 array[m][n],二维数组代表网格地图 array[i][j]0,代表i行j列是空旷位置 a…

基于STM32的智能晾衣设计

1.简介 本设计的目的是开发一种湿度传感智能衣物干燥杆系统,这是一个由单片机控制芯片控制的实时检测系统。该系统使用 DHT11温湿度传感器,检测大气的温度和湿度,然后处理信息,控制电机,完成衣物的收集和干燥工作。  …