k8s部署微服务springcloud从0-1(微服务环境搭建和项目创建)

网友投稿 330 2022-09-12

k8s部署微服务springcloud从0-1(微服务环境搭建和项目创建)

一.数据库服务准备

1.1 mysql准备

#安装mysql docker run -itd --name mysql-test -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql #创建数据库和表 create database docker; create table `tb_article`( `id` INT UNSIGNED AUTO_INCREMENT, `title` VARCHAR(100) NOT NULL, `content` MEDIUMTEXT, `author` varchar(100) NOT NULL, `addtime` DATETIME, PRIMARY KEY ( `id` ) )ENGINE=InnoDB DEFAULT CHARSET=utf8;

1.2 redis准备

docker run -di --name=redis -p 6379:6379 redis

二.微服务搭建

2.1 文章微服务搭建

2.2配置pom

4.0.0 cn.sm1234 sm1234_parent pom 1.0-SNAPSHOT sm1234_article sm1234_eureka sm1234_zuul org.springframework.boot spring-boot-starter-parent 2.2.2.RELEASE UTF-8 UTF-8 1.8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test spring-snapshots Spring Snapshots https://repo.spring.io/snapshot true spring-milestones Spring Milestones https://repo.spring.io/milestone false spring-snapshots Spring Snapshots https://repo.spring.io/snapshot true spring-milestones Spring Milestones https://repo.spring.io/milestone false org.springframework.cloud spring-cloud-dependencies Hoxton.SR1 pom import

2.3新建article微服务模块

2.4配置article模块pom

sm1234_parent cn.sm1234 1.0-SNAPSHOT 4.0.0 sm1234_article 8 8 org.springframework.boot spring-boot-starter-data-jpa mysql mysql-connector-java org.springframework.cloud spring-cloud-starter-netflix-eureka-client

2.5配置微服务配置文件resources/application.yml

server: port: 9001 spring: application: name: sm1234-article datasource: url: jdbc:mysql://127.0.0.1:3306/docker?characterEncoding=UTF8 driver-class-name: com.mysql.cj.jdbc.Driver username: root password: 123456 jpa: database: mysql show-sql: true generate-ddl: true eureka: client: register-with-eureka: true fetch-registry: true service-url: defaultZone: http://127.0.0.1:7000/eureka instance: instance-id: article.com prefer-ip-address: true

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:公关界007:英国成人尿布,靠三位40岁女性户外维密广告一炮而红!
下一篇:守护荔枝尊严,全力备战营销季,茂名火力全开……!
相关文章

 发表评论

暂时没有评论,来抢沙发吧~