gradle 配置
jar {
enabled = false
}
bootJar {
enabled = true
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
}
}
//相关依赖调整成 compileOnly
dependencies {
//compileOnly implementation
compileOnly('org.apache.hbase:hbase-client:2.1.1-cdh6.3.2')
compileOnly('org.apache.hbase:hbase-server:2.1.1-cdh6.3.2')
compileOnly 'org.springframework.boot:spring-boot-starter'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
}
运行
java -Dloader.path=libs -jar hbase-read-hfile-0.0.1-SNAPSHOT.jar
参考
- https://medium.com/saas-startup-factory/spring-boot-2-and-external-libs-with-the-propertieslauncher-fc49d2d93636
- https://docs.spring.io/spring-boot/docs/2.7.12/reference/htmlsingle/#appendix.executable-jar.property-launcher