Spring Boot

Spring Boot 2.2.x JPA配置

2020-03-31  本文已影响0人  EasyNetCN

配置文件bootstrap.yml(Spring Cloud),Spring Boot为application.yml

spring:
  application:
    name: user-service
    
  profiles:
    active: development-local
  codec:
    max-in-memory-size:
      -1
  cloud:
    consul:
      host: ${consul.host:localhost}
      port: ${consul.port:8500}
      discovery:
        prefer-ip-address: true
      config:
        enabled: true
        format: yaml
        default-context: ${spring.application.name}
    loadbalancer:
      ribbon:
        enabled: false
    stream:
      kafka:
        binder:
          brokers: ${kafka.brokers:localhost:9092}
          auto-add-partitions: false
          auto-create-topics: false
      bindings:
        log-service-topic-output: # 消息订阅通道
          destination: log-service-topic  # topic
          contentType: application/json
          producer:
            partition-key-expression:  headers['partitionKey']
            partition-count: 2
      default-binder: kafka
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone:
      Asia/Shanghai
  jpa:
    show-sql: false
  datasource:
    url: jdbc:mysql://${db.host:localhost}:${db.port:3306}/${db.name:user}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&autoReconnect=true
    username: ${db.username:root}
    password: ${db.password:dev}
    hikari:
      data-source-properties:
        cachePrepStmts: true
        prepStmtCacheSize: 500
        prepStmtCacheSqlLimit: 2048
        useServerPrepStmts: true
        useLocalSessionState: true
        useLocalTransactionState: true
        rewriteBatchedStatements: true
        cacheResultSetMetadata: true
        cacheServerConfiguration: true
        elideSetAutoCommits: true
        maintainTimeStats: false
@Configuration
@EnableJpaAuditing
@EnableTransactionManagement
@EntityScan("此处是数据实体entity包名")
@EnableJpaRepositories("此处是数据仓库repository包名")
public class UserJpaConfig {

}
上一篇 下一篇

猜你喜欢

热点阅读