不要再乱搞了,找不到第三方库(依赖)的类,直接使用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()
}
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐