当前位置:网站首页>Gradle的安装配置
Gradle的安装配置
2022-08-03 05:09:00 【*super】
一、下载与安装
下载并解压(CSDN4文件夹或者官网:Gradle Build Tool)
二、配置环境变量
1.新建变量GRADLE_HOME,变量值为文件夹路径。
2.Path中新增%GRADLE_HOME%\bin
3.测试:cmd---gradle -v
(指定仓库配置:GRADLE_USER_HOME,仓库地址)
三、配置Gradle
1.Gradle文件夹---init.d文件夹---新建init.gradle文件
内容:
allprojects {
repositories{
maven { url 'file:D:/JAVA3/1.21/maven/localrepository'}//maven本地仓库地址
mavenLocal()
maven { name "Alibaba"; url"https://maven.aliyun.com/repository/public"}
mavenCentral()
}
}
2.idea配置
类似Maven,找到Gradle,修改仓库地址为Maven仓库地址。
四、创建Gradle工程
参考Maven工程创建。
五、依赖导入
1.更改配置地址
2.复制Maven依赖,会自动识别并更改格式,如:implementation 'org.apache.poi:poi:5.2.0'
注意:低版本的Gradle需要将
implementation
替换成compile
3.刷新依赖
六、文件打包
1.打开bulid.gradle,在plugins中添加id 'application'
2.增加jar选项并修改配置
七、其他知识点
1.mirrors 镜像仓库
<mirrors>
<!--阿里云镜像-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
2.仓库repositories
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
3.pluginRepositories插件仓库
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
4.pom文件配置
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>pom-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- 依赖管理,添加在其中的依赖会被导入-->
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<!-- 依赖管理,这里配置了之后不会实际导入,只是指定了导入版本,其子模块就可以直接使用而不需要指定版本了-->
<dependencyManagement>
</dependencyManagement>
<!-- maven编译和打包处理-->
<build>
<!-- 插件配置,将项目打包成一个可执行的jar包,并将依赖打包进去-->
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-- 此处指定main方法入口的class -->
<mainClass>pom.demo.PomDemo</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- 指定jar包名称-->
<finalName>pom-demo</finalName>
</build>
</project>
边栏推荐
猜你喜欢
Install IIS services (Internet Information Services (Internet Information Services, abbreviated IIS, Internet Information Services)
高可用 两地三中心
typescript41-class类的私有修饰符
Bubble sort in c language structure
在线密码生成工具推荐
链动2+1模式简单,奖励结构丰厚,自主裂变?
【Harmony OS】【ARK UI】轻量级数据存储
【Harmony OS】【FAQ】鸿蒙问题合集1
接口和协议
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
随机推荐
Talking about GIS Data (5) - Geographic Coordinate System
unity2D横板游戏教程6-敌人AI以及受击动画
WebSocket的实际应用
typescript47-函数之间的类型兼容性
BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
Flink状态
Peptides mediated PEG DSPE of phospholipids, targeted functional materials - PEG - RGD/TAT/NGR/APRPG
Interface test practice | Detailed explanation of the difference between GET / POST requests
shell脚本循环语句
Get the Ip tool class
获取Ip工具类
UV decomposition of biotin - PEG2 - azide | CAS: 1192802-98-4 biotin connectors
接口测试框架实战(二)| 接口请求断言
Interface testing framework of actual combat (2) | interface request assertion
【精讲】利用原生js实现todolist
CobalStrike(CS)基础超级详细版
Power button 561. An array of split
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface