微服务 SpringCloude源码以及源码编译
将 SpringCloud 微服务项目部署至 K8S 平台,以下步骤均在 k8s 的 master1 节点操作
Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的项目管
理工具软件
(1)安装 openjdk 和 maven
在 k8s 的 master1 节点操作:
yum install java-1.8.0-openjdk maven-3.0.5* -y
(2)上传微服务源码包到 k8s 的 master 节点
unzip microservic-test.zip
cd microservic-test
[root@master microservic-test]# ls
basic-common eureka-service k8s lombok.config pom.xml product-service stock-service
db gateway-service LICENSE order-service portal-service README.md
(3)在 k8s 的 master1 节点操作
1)修改库存数据库
[root@master ~]# cd microservic-test
[root@master microservic-test]# cd stock-service/
[root@master stock-service]# ls
pom.xml stock-service-api stock-service-biz
[root@master stock-service]# cd stock-service-biz/
[root@master stock-service-biz]# ls
Dockerfile pom.xml src target
[root@master stock-service-biz]# cd src/
[root@master src]# ls
main
[root@master src]# cd main/
[root@master main]# ls
java resources
[root@master main]# cd resources/
[root@master resources]# ls
application-dev.yml application-fat.yml application.yml
[root@master resources]# vim application-fat.yml
spring:
datasource:
url: jdbc:mysql://192.168.0.12:3306/tb_stock?characterEncoding=utf-8
[root@master microservic-test]# cd product-service/
就是将order,product,stock数据库的地址都修改为自己的数据库地址。
(4)通过 Maven 编译、构建、打包源代码
在 k8s 的 master1 节点操作
修改源代码之后回到/root/microservic-test 目录下执行如下命令:
[root@master microservic-test]# mvn clean package -D maven.test.skip=true
[INFO] Reactor Summary:
[INFO]
[INFO] simple-microservice ............................... SUCCESS [27.833s]
[INFO] basic-common ...................................... SUCCESS [0.003s]
[INFO] basic-common-core ................................. SUCCESS [5:44.058s]
[INFO] gateway-service ................................... SUCCESS [3:35.291s]
[INFO] eureka-service .................................... SUCCESS [18.275s]
[INFO] product-service ................................... SUCCESS [0.002s]
[INFO] product-service-api ............................... SUCCESS [0.334s]
[INFO] stock-service ..................................... SUCCESS [0.001s]
[INFO] stock-service-api ................................. SUCCESS [0.325s]
[INFO] product-service-biz ............................... SUCCESS [5.588s]
[INFO] stock-service-biz ................................. SUCCESS [0.545s]
[INFO] order-service ..................................... SUCCESS [0.001s]
[INFO] order-service-api ................................. SUCCESS [0.304s]
[INFO] order-service-biz ................................. SUCCESS [0.630s]
[INFO] basic-common-bom .................................. SUCCESS [0.001s]
[INFO] portal-service .................................... SUCCESS [1.091s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10:28.566s
[INFO] Finished at: Wed Jun 09 09:19:55 CST 2021
[INFO] Final Memory: 68M/326M
[INFO] ------------------------------------------------------------------------
[root@master microservic-test]# ls
basic-common eureka-service k8s lombok.config pom.xml product-service stock-service
db gateway-service LICENSE order-service portal-service README.md
来看看源码包
[root@master microservic-test]# cd product-service/
[root@master product-service]# ls
pom.xml product-service-api product-service-biz
[root@master product-service]# cd product-service-biz/
[root@master product-service-biz]# ls
Dockerfile pom.xml src target
[root@master product-service-biz]# cd target/
[root@master target]# ls
classes maven-archiver product-service-biz.jar
generated-sources maven-status product-service-biz.jar.original
[root@master microservic-test]# ls order-service/order-service-biz/target/
classes maven-archiver order-service-biz.jar
generated-sources maven-status order-service-biz.jar.original
[root@master microservic-test]# ls stock-service/stock-service-biz/target/
classes maven-archiver stock-service-biz.jar
generated-sources maven-status stock-service-biz.jar.original
目录 返回
首页