当前位置:网站首页>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>
边栏推荐
- 超好用的画图工具推荐
- 安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
- Power button 561. An array of split
- 【Harmony OS】【ARK UI】轻量级数据存储
- GIS数据漫谈(五)— 地理坐标系统
- 【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
- Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
- Harmony OS ets ArkUI 】 【 】 the development basic page layout and data connection
- 2022暑假牛客多校联赛第一场
猜你喜欢
【HMS core】【Ads Kit】Huawei Advertising——Overseas applications are tested in China. Official advertisements cannot be displayed
typescript40-class类的保护修饰符
typescript49-交叉类型
typescript44-对象之间的类兼容器
【生物素叠氮化物|cas:908007-17-0】价格_厂家
tag单调栈-单调栈预备知识-lt.739. 每日温度
13.< tag-动态规划和回文字串>lt.647. 回文子串 + lt.516.最长回文子序列
DFS对剪枝的补充
在线密码生成工具推荐
安装IIS服务(Internet信息服务(Internet Information Services,简写IIS,互联网信息服务)
随机推荐
探索性测试的概念及方法
在树莓派上搭建属于自己的网页(1)
Odps temporary query can write SQL, turned out to a named?
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
typescript49-交叉类型
js中的闭包
Interface test practice | Detailed explanation of the difference between GET / POST requests
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
User password verification
[Harmony OS] [ArkUI] ets development graphics and animation drawing
typescript43-类型兼容性说明
【Biotin Azide|cas:908007-17-0】Price_Manufacturer
内部类、static关键字、final
WebSocket的实际应用
rosbag工具plotjuggler无法打开rosbag的问题
Interface test framework combat (1) | Requests and interface request construction
用户密码加密工具
js的垃圾回收机制
Harmony OS Date ano UI 】 【 】 the basic operation
接口和协议