springboot 常用开发小技巧

1,热插拔 

 
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

 

springboot 常用开发小技巧

2 集成pageHepler

#分页配置  在PageHelper.java中配置
pagehelper:
  helper-dialect: mysql
  reasonable: true
  support-methods-arguments: true
  params: count=countSql

3 集成mybatis

#mybatis配置
mybatis:
  config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations:  classpath:mybatis/mapper/*.xml
  type-aliases-package: com.chinada.dms.mybatis.model
  check-config-location: true

4 集成mysql

#正式环境配置一(客户服务器-生产)================================================================================================
---
spring:
  profiles: prod
  #DB配置
  datasource:
    url: jdbc:mysql://localhost:3306/dms_pro?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
#测试服务器配置二(本地服务器-测试)================================================================================================
---
spring:
  profiles: test
  #DB配置
  datasource:
    url: jdbc:mysql://192.168.0.123:3306/dms_test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
    username: dms
    password: 123qaz

5 集成thymeleaf

  #前段html映射框架设置
  thymeleaf:
    cache: true
    mode: HTML
  #最大上传文件大小和最大请求大小
  servlet:
    multipart:
      max-file-size: 20MB
      max-request-size: 20MB

#端口号的设定
server:
  port: 8081

6 集成日志打印

# 打印sql
logging:
  level:
     com.chinada.dms.mybatis.mapper: info
     #设置debug,显示sql打印显示