创建两个springboot maven子项目
子项目名称分别为order-server和user-server
配置user-server子项目:
所需依赖:
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId> </dependency><!--mybatis--> <dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId> </dependency>
数据库表数据:
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0;-- ---------------------------- -- Table structure for tb_user -- ---------------------------- DROP TABLE IF EXISTS `tb_user`; CREATE TABLE `tb_user` (`id` bigint(20) NOT NULL AUTO_INCREMENT,`username` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '收件人',`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '地址',PRIMARY KEY (`id`) USING BTREE,UNIQUE INDEX `username`(`username`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 109 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;-- ---------------------------- -- Records of tb_user -- ---------------------------- INSERT INTO `tb_user` VALUES (1, '柳岩', '湖南省衡阳市'); INSERT INTO `tb_user` VALUES (2, '文二狗', '陕西省西安市'); INSERT INTO `tb_user` VALUES (3, '华沉鱼', '湖北省十堰市'); INSERT INTO `tb_user` VALUES (4, '张必沉', '天津市'); INSERT INTO `tb_user` VALUES (5, '郑爽爽', '辽宁省沈阳市大东区'); INSERT INTO `tb_user` VALUES (6, '范兵兵', '山东省青岛市');SET FOREIGN_KEY_CHECKS = 1;
配置文件:
server:port: 9000 spring:datasource:# 本地数据库配置url: jdbc:mysql://localhost:3306/cloud_user?u