SpringBoot构建微服务实战 之 服务注册的快速打包
上一节我们学习了SpringBoot + Zookeeper 来构建微服务并服务注册到Zookeeper中去。下面我将介绍一种企业级应用的打包方式用来提供运营支持。即使用 appassembler-maven-plugin 来快速打包、部署、运行SpringBoot 服务
-
官方介绍:
- The Application Assembler Plugin is a Maven plugin for generating scripts for starting java applications. All dependencies and the artifact of the project itself are placed in a generated Maven repository in a defined assemble directory. All artifacts (dependencies + the artifact from the project) are added to the classpath in the generated bin scripts.
通常理解:
- Appassembler 是Maven 的一个构造组件,其目的在于生成可运行的脚本(同时支持Win.和Unix.)来启动java 应用程序。同时将项目的所有依赖(jar的形式)统一打包放在指定的路径下以支持应用程序的运行。
实例
前面我们学习了微服务的注册,但毕竟是在Eclipse IDE中启动的。总的来说运行方式不友好,因而我们想通过直接运行一个脚本就能将我们的服务拉起来,这样运维人员便可以随时接手我们的部分工作进而一定程度上减轻我们的工作量(不是为了偷懒- -!)。下面我们将来实现一下~~
在pom.xml 做声明:
<build> <plugins> <plugin> <!-- http://www.mojohaus.org/appassembler/appassembler-maven-plugin/index.html --> <groupId>org.codehaus.mojo</groupId> <artifactId>appassembler-maven-plugin</