SpringBoot常用配置yml模板与启动类

 

 yml在博客园插入代码时选择python才能正常匹配使用啊。

注意,#在yml中是注释的意思。

 

# Tomcat
server:
  tomcat:
    uri-encoding: UTF-8
    max-threads: 1000
    min-spare-threads: 30
  port: 8080
  servlet:
    context-path: /city
spring:
  jmx:
    default-domain: city
  devtools: 
    restart: 
      enabled: true
  profiles:
    active: dev
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB
      enabled: true
  freemarker:
    suffix: .html
    request-context-attribute: request
  datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        platform: oracle
        driver-class-name: oracle.jdbc.driver.OracleDriver
        url: jdbc:oracle:thin:@127.0.0.1:8080:orcl
        username: city
        password: city
        initialSize: 5
        minIdle: 5
        maxActive: 20
        maxWait: 60000
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: SELECT 1 FROM DUAL
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        filters: stat,wall,log4j
        logSlowSql: true
#mybatis
mybatis-plus:
  mapper-locations: classpath:mapper/*.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.wanli.*.entity
  global-config:
    #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
    #id-type: 0
    #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
    field-strategy: 2
    #刷新mapper 调试神器
    refresh-mapper: true
    #数据库大写下划线转换
    capital-mode: true
    # Sequence序列接口实现类配置
    #key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
    #逻辑删除配置
    logic-delete-value: -1
    logic-not-delete-value: 0
    #自定义填充策略接口实现
    #meta-object-handler: com.baomidou.springboot.xxx
    db-config:
      db-type: oracle
  configuration:
    map-underscore-to-camel-case: true 
    cache-enabled: false
    call-setters-on-nulls: true 
    jdbc-type-for-null: null  
 
logging:
  level:
     com.supermap.ggzy.city.dao : debug

 

启动类:

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
@ServletComponentScan
@MapperScan("com.baomidou.mybatisplus.samples.quickstart.mapper")
public class CityApplication  extends SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(CityApplication.class, args);
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(CityApplication.class);   
    } 
}

 

posted @ 2021-04-26 14:09  万里哥  阅读(664)  评论(0编辑  收藏  举报