概述
springCloud微服务之订单微服务注册
订单微服务与用户微服务创建过程相似,这里只贴出重要配置
创建订单数据库和表结构
这里需要注意的是,创建表名最好加前缀,由于order是order by的关键字,也是mysql的保留关键字,如果直接用order命名查询不是很方便,还需要用单引号包裹,表名和表字段最好都用前缀来区分会好一点。
create schema cloud_order collate utf8mb4_0900_ai_ci;
create table c_order
(
id char(32) not null,
order_no varchar(50) not null comment '订单号',
order_status char default '0' not null comment '0 创建 1 完成 2 删除',
finish_date datetime null comment '完成日期',
delete_date datetime null comment '删除日期',
create_date datetime not null,
create_by char(32) not null,
update_date datetime not null,
update_by char(32) not null,
amount double not null,
constraint order_id_uindex
unique (id)
)
comment '订单';
alter table c_order
add primary key (id);
create table c_order_detail
(
id char(32) not null,
order_id char(32) null comment '订单id',
good_id char(32) not null comment '商品ID',
good_name varchar(50) not null comment '商品名称',
price double not null comment '商品价格',
quantity int not null comment '商品数量',
amount double null comment '总金额',
create_date datetime not null,
create_by char(32) not null,
update_date datetime not null,
update_by char(32) null,
constraint order_detail_id_uindex
unique (id),
constraint c_order_detail_c_order_id_fk
foreign key (order_id) references c_order (id)
on update cascade on delete cascade
)
comment '订单明细';
alter table c_order_detail
add primary key (id);
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">
<parent>
<artifactId>Spring-cloud-study</artifactId>
<groupId>com.jdpay</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-order</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<!--服务客户端 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
</project>
application.yml
server:
port: 8883
servlet:
context-path: /
spring:
datasource:
name: druidDataSource
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
username: root
password: 123456
druid:
filters: stat ,wall,log4j, config
max-active: 100
initial-size: 1
max-wait: 60000
min-idle: 1
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
validation-query: select 'x'
test-while-idle: true
test-on-borrow: false
test-on-return: false
pool-prepared-statements: true
max-open-prepared-statements: 50
max-pool-prepared-statement-per-connection-size: 20
web-stat-filter:
exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"
url-pattern: /*
tat-view-servlet:
allow: 127.0.0.1
deny: apg-server
login-username: admin
login-password: admin
reset-enable: true
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
show-sql: true
hibernate:
ddl-auto: none
application:
name: spring-cloud-order
eureka:
instance:
hostname: eureka1
client:
service-url:
defaultZone: http://localHost:8801/eureka
og4j.properties
与用户相同
最后
以上就是清秀戒指为你收集整理的springCloud微服务之订单微服务注册springCloud微服务之订单微服务注册的全部内容,希望文章能够帮你解决springCloud微服务之订单微服务注册springCloud微服务之订单微服务注册所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复