happyyangyuan / springcloud-quickstart

spring cloud demo based on gradle.
Apache License 2.0
115 stars 24 forks source link

依赖统一管理之后,如何分开打成jar包 #6

Closed cuifuan closed 5 years ago

cuifuan commented 5 years ago

我想分开module打包分开部署,现在就是打包之后找不到依赖

happyyangyuan commented 5 years ago

你好,我理解的你的需求是单独为某个module进行build出jar包吧?

可以直接进入到指定的module路径内执行gradle build命令,构建输出的jar包在build/libs内。

以api-gateway/zuul为例:

happyyangyuan:springcloud-quickstart happyyangyuan$ cd api-gateway/zuul/
happyyangyuan:zuul happyyangyuan$ gradle build
include :api-gateway:zuul
include :config:config-reader-with-bus
include :config:config-reader-with-bus0
include :config:config-reader
include :config:config-server
include :discovery:eureka-demo-client
include :discovery:eureka-server
include :discovery:eureka-demo-client0
include :call-chain:zipkin-clients:zipkin-client
include :call-chain:zipkin-clients:zipkin-client1
include :call-chain:zipkin-clients:zipkin-client0
include :call-chain:zipkin-server
include :routing:routing-feign
include :routing:routing-ribbon

BUILD SUCCESSFUL in 3s
5 actionable tasks: 3 executed, 2 up-to-date
happyyangyuan:zuul happyyangyuan$ ls build/libs/
zuul-0.0.1-SNAPSHOT.jar         zuul-0.0.1-SNAPSHOT.jar.original
happyyangyuan:zuul happyyangyuan$ java -jar build/libs/zuul-0.0.1-SNAPSHOT.jar
2019-02-15 10:47:20.929  INFO 50767 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@48533e64: startup date [Fri Feb 15 10:47:20 CST 2019]; root of context hierarchy
2019-02-15 10:47:21.582  INFO 50767 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-02-15 10:47:21.802  INFO 50767 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$3c5b44cd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.8.RELEASE)
happyyangyuan commented 5 years ago

目前在根目录内执行gradle build确实还有些问题,那种空的父module构建时会报错提示Could not set unknown property 'mainClassName' for project ':api-gateway',这个需要在build.gradle内指定这种空的父module直接跳过构建步骤才行,我后面有时间的话会补上这个gradle脚本。

cuifuan commented 5 years ago

好的,谢谢 !