代码实操
创建父工程: microservicecloud
创建公共模块api:microservicecloudapi
SQL脚本: 此学习路线总共创建3个库, 分别为clouddb01, clouddb02, clouddb03
1 /* 2 Navicat Premium Data Transfer 3 4 Source Server : localhost_3306 5 Source Server Type : MySQL 6 Source Server Version : 50717 7 Source Host : localhost:3306 8 Source Schema : clouddb01 9 10 Target Server Type : MySQL 11 Target Server Version : 50717 12 File Encoding : 65001 13 14 Date: 12/06/2018 13:31:53 15 */ 16 17 SET NAMES utf8mb4; 18 SET FOREIGN_KEY_CHECKS = 0; 19 20 -- ---------------------------- 21 -- Table structure for dept 22 -- ---------------------------- 23 DROP TABLE IF EXISTS `dept`; 24 CREATE TABLE `dept` ( 25 `deptno` bigint(20) NOT NULL AUTO_INCREMENT, 26 `dname` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 27 `db_source` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, 28 PRIMARY KEY (`deptno`) USING BTREE 29 ) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; 30 31 -- ---------------------------- 32 -- Records of dept 33 -- ---------------------------- 34 INSERT INTO `dept` VALUES (1, '开发部', DATABASE()); 35 INSERT INTO `dept` VALUES (2, '人事部', DATABASE()); 36 INSERT INTO `dept` VALUES (3, '财务部', DATABASE()); 37 INSERT INTO `dept` VALUES (4, '市场部', DATABASE()); 38 INSERT INTO `dept` VALUES (5, '运维部', DATABASE()); 39 40 SET FOREIGN_KEY_CHECKS = 1;
创建部门服务提供者模块:microservicecloudproviderdept8001
注意:用postman测试add接口时得在Headers中添加此属性及在Body中选择raw选项及JSON(application/json)
小技巧:选中raw及JSON(application/json)时,Headers中Content-Type属性postman会自动添加
若是选择form-data测试会报错, 因为我们后台接口接收参数时是用@RequestBody修饰的。
创建部门服务消费者模块:microservicecloudconsumerdept80