Met a X DAO系统、freedom自由协议等系统目前在市面上很流行,现在让我们来看看关于开发它们的一些注意事项。 一、工程结构
本章内容需要修改内容比较多,涉及到以下三个工程模块的修改:
base-grpc-framework-core:主要改动点是在service中集成dao接口
base-grpc-framework-dao:数据库存储实现;
base-grpc-framework-application:主要改动点是添加数据库配置;
主要的改动文件如下图红框内所示,本章我们因为DAO是个全新的模块,所以本章会按工程修改的多少来罗列,先app,再core,最后dao:
二、修改启动配置,集成mysql
修改【base-grpc-framework-application】模块的application-dev.yml文件,完整的内容如下,新增了第11到14行:
# http配置
server:
compression:
enabled: true
mime-types: application/json,application/octet-stream
# spring配置
spring:
application:
name: GrpcFramework-Server-APP
aop:
auto: true
proxy-target-class: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Drive
url: jdbc:mysql://127.0.0.1:3306/badCase?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: 12345678
druid:
initial-size: 20
min-idle: 20
max-active: 400
max-wait: 60000
validation-query: SELECT 1 FROM DUAL
max-pool-prepared-statement-per-connection-size: 20
test-while-idle: true
test-on-borrow: false
test-on-return: false
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 100000
filters: stat
# grpc Server配置
grpc:
server:
port: 9898 #发布远程访问地址
in-process-name: native #发布本地访问地址
client:
inProcess:
address: in-process:native #配置内部访问服务名称
# mybatis plug 配置
mybatis-plus:
mapper-locations: classpath:/mybatis/*Mapper.xml
configuration:
map-underscore-to-camel-case: true # 开启驼峰命名规则映射
default-statement-timeout: 10 #超时查询
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql日志
# logging日志配置
logging:
config: classpath:log4j2.xml
level:
root: INFO
org.springframework.web: ERROR