玩转微服务-手把手教你搭建 接着上一篇框架的介绍,现在教大家如何搭建!~ 工具:idea开发工具,apache-maven-3.5.3 java环境:jdk1.8 springboot1.5.4 一,首先我们搭建父级专案(为何要建父级专案呢?上篇有介绍我就不多说了) 1.新建父级专案及各子模组,如下图 2.微服务方便之处就是减少配置,父级Pom直接引入jar包 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd> 4.0.0 org.springframework.boot spring-boot-starter-parent 1.5.4.RELEASE com.zw parent-yl pom 1.0-SNAPSHOT parent-yl parent-chis parent-public parent-common parent-sign UTF-8 1.9.2 1.2.33 3.5.0 4.5.2 3.3.2 2.9.0 2.9.9 1.11.3 2.7.0 1.3.2 1.2.3 1.9.13 2.5.0 4.1.6 1.3.2 6.0.3 11.2.0.4 3.4.4 2.2.2 1.3.2 1.1.6 2.8.2 releases User Project Release http://47.107.129.252:8081/repository/maven-releases/ snapshots User Project SNAPSHOTS http://47.107.129.252:8081/repository/maven-snapshots/ org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-aop org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-data-redis org.springframework.session spring-session-data-redis org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 org.jacoco jacoco-maven-plugin 0.8.1-SNAPSHOT src/main/resources **/*.properties **/*.xml **/*.tld true src/main/java **/*.xml true 3.父级服务包打入本地仓库,如下图表示成功 二,搭建子服务包,比如建yl-public 1.新建yl-public及建启动类Application(随便取名) 2.继承父级Pom档案jar包,引入父级模组(parent-public,parent-common),指定启动类 com.zw parent-yl 1.0-SNAPSHOT com.zw parent-public 1.0-SNAPSHOT com.zw parent-common 1.0-SNAPSHOT com.alibaba fastjson ${fastjson.version} org.springframework.boot spring-boot-maven-plugin 1.5.4.RELEASE com.zw.yl.basic.Application repackage 3.检视依赖父级包相关jar包己引入 4.点选执行,启动成功检视 5.如打成可执行jar包放入服务器启动 后台命令列启动: nohup java -jar yl-public-1.0-SNAPSHOT.jar --spring.profiles.active=dev & 后台执行启动,即使当前命令窗品关闭,程序也不会关掉 OK,看效果 谢谢大家多多关注,想要程式码及学习资料的关注私信我,谢谢!!!