不要再乱搞了,找不到第三方库(依赖)的类,直接使用shadow,只需两步,轻松愉快
- 添加插件, build.gradle中添加插件
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'java'
}
- 等一会,使用下面的命令进行打包。
结果可以直接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()
}