gradle打包项目和依赖(第三方库)

不要再乱搞了,找不到第三方库(依赖)的类,直接使用shadow,只需两步,轻松愉快

  1. 添加插件, build.gradle中添加插件
plugins {
    id 'com.github.johnrengelman.shadow' version '2.0.4'
    id 'java'
}
  1. 等一会,使用下面的命令进行打包。
    在这里插入图片描述

结果可以直接jar -jar运行了
在这里插入图片描述

完整的build.gradle文件



plugins {
    id 'com.github.johnrengelman.shadow' version '2.0.4'
    id 'java'
}

group 'org.springframework'
version '5.1.10.ZHONG-RELEASE'
sourceCompatibility = 1.8



jar {
// 指定主类信息。
   manifest {
        attributes 'Main-Class': 'com.fuzekun.springTest.importSelector.TestMain'
    }
}
repositories {
    maven { url "https://maven.aliyun.com/repository/public"}
    maven { url 'https://maven.aliyun.com/repository/central' }
    maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
    maven { url "https://maven.aliyun.com/repository/spring-plugin"}

    maven { url "https://repo.spring.io/plugins-release" }
}
dependencies {
//    添加模块需要的依赖
    implementation(project(":spring-beans"))
    implementation(project(":spring-core"))
    implementation(project(":spring-context"))
    implementation(project(":spring-aop"))
    compileOnly 'org.projectlombok:lombok:1.18.8'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
test {
    useJUnitPlatform()
}
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值