springboot --- --- integration druid connection pool connect oracle database integration mybatis --- --- integration thymeleaf --- log configuration

Xintian rely druid connection pool in the new springboot project pom file

  <-! Druid Database Connection Pool ->
     <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid-spring-boot-starter</artifactId>
      <version>1.1.9</version>
     </dependency>

Then add a configuration profile in application.properties

# Spring.datasource.druid.driver-class-name = oracle.jdbc.driver.OracleDriver can be equipped unworthy, Ali database connection pool will automatically search through url
spring.datasource.druid.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.druid.username=scott
spring.datasource.druid.password=tiger
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=20
spring.datasource.druid.min-idle=10
spring.datasource.druid.max-wait=10
# Whether to cache preparedStatement, which is PSCache. PSCache support database cursors huge performance boost, for example oracle.
# Mysql5.5 not PSCache function in the following version, it is recommended to close off.
#spring.datasource.druid.pool-prepared-statements=true
# Intervals the frequency of such detection, an idle connection is detected to be closed in milliseconds
spring.datasource.druid.time-between-eviction-runs-millis=60000
# Configure a minimum survival time connection pool, in milliseconds
spring.datasource.druid.min-evictable-idle-time-millis=300000
# Configure extension: monitor filter statistical purposes: stat logs with the filter: log4j defense sql injection filter: wall
#spring.datasource.druid.filters=stat,wall
#spring.datasource.druid.filter.stat.log-slow-sql=true
#spring.datasource.druid.filter.stat.slow-sql-millis=2000

Static configuration file directory and template files directory

Create a folder
Static files directory: src \ main \ resources \ static
Template files directory: src \ main \ resources \ templates
Add thymeleaf dependencies
<-! Thymeleaf template package ->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>  

Add Configuration

Before configuring a static resource suffix #
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
#spring.thymeleaf.mode=HTML5
#spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.servlet.content-type=text/html
# Recommended the development of the spring.thymeleaf.cache set to false, or there will be cached page can not lead in time to see the effect of the updated
#spring.thymeleaf.cache=false

Upload configuration

# Configure the path
             upload.path=D:/images/
# Default support file uploads
spring.servlet.multipart.enabled=true
spring.servlet.multipart.file-size-threshold=0
# Upload file size configuration
spring.servlet.multipart.max-file-size=10mb
spring.servlet.multipart.max-request-size=10mb
SM Logging Configuration
Creating logback.xml in resources, into replication configuration
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <! - definition of the log file storage address Do not use a relative path LogBack configuration ->
    <property name="LOG_HOME" value="D:/projects/log" />
    <-! Console output ->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <- Formatting Output:!% D represents the date,% thread indicates that the thread name,% - 5level: Level 5 show left character width% msg: log messages,% n newline ->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
        </encoder>
    </appender>
    <-! According to generate a log file every day ->
    <appender name="FILE"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <! - file name of the log file output ->
            <FileNamePattern>${LOG_HOME}/springbootdemo.log.%d{yyyy-MM-dd}.log</FileNamePattern>
            <! - the number of days to keep log files ->
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <- Formatting Output:!% D represents the date,% thread indicates that the thread name,% - 5level: Level 5 show left character width% msg: log messages,% n newline ->
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
        </encoder>
        <! - the maximum log file size ->
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>10MB</MaxFileSize>
        </triggeringPolicy>
    </appender>




    <!--myibatis log configure-->
    <logger name="com.apache.ibatis" level="DEBUG"/>
    <logger name="java.sql.Connection" level="DEBUG"/>
    <logger name="java.sql.Statement" level="DEBUG"/>
    <logger name="java.sql.PreparedStatement" level="DEBUG"/>


    <-! Log output level
      trace<debug<info<warn<error<fatal
    The relationship between levels are included, meaning that if you set the log level is trace, the logs will be greater than or equal to this level of output.
    trace: a track, is to promote the program, you can write trace output, so the trace should be particularly large, but that's okay, we can not let him set the minimum log level output.
    debug: debug it, I generally only used this as a minimum level, trace they not. It is in no way to use eclipse or the idea of ​​debug function like it.
    info: output or what important information you are interested in, with most of this.
    warn: Some information is not an error message, but also to give some tips programmers, similar verification code has not eclipse error and warn (not an error but please note, such as the depressed method).
    error: error message. It will be more used.
    fatal: a relatively high level. Major error, this level you can stop the program directly, the error should not happen is what! Do not be so nervous, in fact, a matter of degree.
   -->
    <root level="DEBUG">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
    <! - asynchronous log into the database ->
    <!--<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">-->
    <! - <! - asynchronous log into the database -> ->
    <!--<connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">-->
    <! - <! - Connection Pool -> ->
    <!--<dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">-->
    <!--<driverClass>com.mysql.jdbc.Driver</driverClass>-->
    <!--<url>jdbc:mysql://127.0.0.1:3306/databaseName</url>-->
    <!--<user>root</user>-->
    <!--<password>root</password>-->
    <!--</dataSource>-->
    <!--</connectionSource>-->
    <!--</appender>-->
</configuration>

  

Guess you like

Origin www.cnblogs.com/fantongxue/p/11008619.html