标签:interval mon err 控制台 oracle orm 序列 pen data
18、快速开发-配置&测试微服务基本CRUD功能
19、快速开发-逆向生成所有微服务基本CRUD代码
根据之前的博客,把代码抽取,然后把各个模块都建立一下,看了一下代码,感觉配置都很简单,后面再改,先按照教程的来。
下面就那这个模块做个实列:
spring: datasource: username: root password: root url: jdbc:mysql://192.168.1.117:3306/gulimall_pms driver-class-name: com.mysql.jdbc.Driver ##mybatisplus配置 mybatis-plus: #扫描xml文件 mapper-locations: classpath:/mapper/**/*.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.dalianpai.gulimall.product.entity global-config: id-type: 0 #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" field-strategy: 2 #驼峰下划线转换 db-column-underline: true #刷新mapper 调试神器 refresh-mapper: true #数据库大写下划线转换 #capital-mode: true #序列接口实现类配置 #key-generator: com.baomidou.springboot.xxx db-config: logic-delete-value: 0 logic-not-delete-value: 1 # key-generator: # db-config: # key-generator:可能 #db-config: 这个配置已经过时了 #db-type: oracle #自定义SQL注入器 3.1.1版本以后不要加入 #sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector configuration: #开启二级缓存 cache-enabled: false jdbc-type-for-null: null
测试类:
@SpringBootTest class GulimallProductApplicationTests { @Autowired BrandService brandService; @Autowired CategoryService categoryService; @Test void contextLoads() { List<BrandEntity> list = brandService.list(new QueryWrapper<BrandEntity>().eq("brand_id", 1L)); list.forEach(System.out::println); } }
但是没有显示sql,先配置一下。
spring: datasource: username: root password: root # url: jdbc:mysql://192.168.1.117:3306/gulimall_pms #driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.p6spy.engine.spy.P6SpyDriver url: jdbc:p6spy:mysql://192.168.1.117:3306/gulimall_pms
在common里面引入p6spy
在product下面加入配置文件spy.properties
#3.2.1以上使用 #modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory #3.2.1以下使用或者不配置 modulelist=com.p6spy.engine.logging.P6LogFactory,com.p6spy.engine.outage.P6OutageFactory # 自定义日志打印 #logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger logMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat customLogMessageFormat=%(executionTime)ms | %(sqlSingleLine) #日志输出到控制台 #appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger # 使用日志系统记录 sql appender=com.p6spy.engine.spy.appender.Slf4JLogger # 设置 p6spy driver 代理 deregisterdrivers=true # 取消JDBC URL前缀 useprefix=true # 配置记录 Log 例外,可去掉的结果集有error,info,batch,debug,statement,commit,rollback,result,resultset. excludecategories=info,debug,result,commit,resultset # 日期格式 dateformat=yyyy-MM-dd HH:mm:ss # 实际驱动可多个 #driverlist=org.h2.Driver # 是否开启慢SQL记录 outagedetection=true # 慢SQL记录标准 2 秒 outagedetectioninterval=2
2020-05-26 11:15:53.111 INFO 4308 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2020-05-26 11:15:56.455 INFO 4308 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2020-05-26 11:15:56.531 INFO 4308 --- [ main] p6spy : 38ms | SELECT brand_id,name,logo,show_status,sort,descript,first_letter FROM pms_brand WHERE (brand_id = 1) BrandEntity(brandId=1, name=null, logo=e‘e, descript=e, showStatus=null, firstLetter=null, sort=null) 2020-05-26 11:15:56.581 INFO 4308 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService ‘applicationTaskExecutor‘ 2020-05-26 11:15:56.586 INFO 4308 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2020-05-26 11:15:57.026 INFO 4308 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
标签:interval mon err 控制台 oracle orm 序列 pen data
原文地址:https://www.cnblogs.com/dalianpai/p/12964359.html