application.properties
#dataSource
spring.datasource.name=mydb
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.24.47:3306/test_s?useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=test@chinac.com!@#
spring.datasource.max-active=1000
#spring.datasource.test-on-borrow=true
#spring.datasource.test-on-return=true
#mybatis
mybatis.mapperLocations=classpath*:tutorial/springboot/dao/mapper/*.xml
mybatis.typeAliasesPackage=tutorial.springboot.model
#log
logging.path=./logs
logging.file=Log
注意:mybatis配置除了上面常见的两项配置,还有:
mybatis.config:mybatis-config.xml配置文件的路径
mybatis.typeHandlersPackage:扫描typeHandlers的包
mybatis.checkConfigLocation:检查配置文件是否存在
mybatis.executorType:设置执行模式(SIMPLE, REUSE, BATCH),默认为SIMPLE
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- <include resource="org/springframework/boot/logging/logback/base.xml" /> -->
<!-- <logger name="org.springframework.web" level="INFO"/> -->
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder><!-- 格式化输出 -->
<pattern>[%d{yyyy-MM-dd'T'HH:mm:ss.SSS}] %level - %m%n</pattern>
</encoder>
</appender>
<!-- 控制台输出级别 -->
<root level="info">
<appender-ref ref="console" />
</root>
<!-- 文件输出 -->
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${LOG_FILE}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd,aux}/${LOG_FILE}-%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>180</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder><!-- 必须指定,否则不会往文件输出内容 -->
<pattern>[%d{yyyy-MM-dd'T'HH:mm:ss.SSS}] %level ${LOG_FILE} %logger : %message%n</pattern>
</encoder>
</appender>
<!-- 文件输出_error -->
<appender name="fileErrorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/${LOG_FILE}-error.log</file>
<!-- 过滤掉ERROR级别以下的日志不输出到文件中 -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_PATH}/%d{yyyy-MM-dd,aux}/${LOG_FILE}-error-%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<maxFileSize>20MB</maxFileSize>
<maxHistory>180</maxHistory>
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>[%d{yyyy-MM-dd'T'HH:mm:ss.SSS}] %level ${LOG_FILE} %logger : %message%n</pattern>
</encoder>
</appender>
<!-- 文件输出级别 -->
<root level="info">
<appender-ref ref="fileAppender" />
<appender-ref ref="fileErrorAppender" />
</root>
<!-- MyBatis打印sql语句 -->
<logger name="tutorial.springboot.dao.BookDao" level="DEBUG"/>
<logger name="tutorial.springboot.dao.AuthorDao" level="DEBUG"/>
</configuration>