product-service-client
1.0-SNAPSHOT
org.apache.maven.plugins
maven-compiler-plugin
1.81.8
src/main/java
**/*.xml
product-service-client pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=“http://maven.apache.org/POM/4.0.0”
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”>
product-service
com.xuweichao
1.0-SNAPSHOT
4.0.0
com.xuweichao
product-service-client
jar
com.baomidou
mybatis-plus-annotation
3.3.0
compile
com.baomidou
mybatis-plus-extension
3.3.0
compile
org.springframework.cloud
spring-cloud-starter-openfeign
数据库建表:订单表 产品表
CREATE TABLE order_base
(
id
bigint(20) NOT NULL AUTO_INCREMENT,
user_name
varchar(10) DEFAULT NULL,
p_id
bigint(20) DEFAULT NULL,
p_name
varchar(50) DEFAULT NULL,
p_price
double(10,2) DEFAULT NULL,
number
int(11) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8
CREATE TABLE product_base
(
id
bigint(20) NOT NULL AUTO_INCREMENT,
name
varchar(100) DEFAULT NULL,
price
double(10,2) DEFAULT NULL,
stock
int(11) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4
使用 代码生成工具生成数据库试题对象和 service
order-service 微服务 添加配置 application.yml
spring:
application:
name: order-service
datasource:
driver-class-name: com.mysql.jdbc.Driver
password: xxx
url: jdbc:mysql://xxx.xxx.xxx.xxx:3306/database-name?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
username: root
server:
port: 18080
swagger:
enable: true
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
product-service 微服务 添加配置 application.yml
spring:
application:
name: product-service
datasource:
driver-class-name: com.mysql.j