application.yml 1.94 KB
spring:
  application:
    name: product-service
  profiles:
    active: prod
  datasource:
    url: jdbc:postgresql://postgresql-service:5432/ecommerce
    username: ${DB_USERNAME:postgres}
    password: ${DB_PASSWORD:password}
    driver-class-name: org.postgresql.Driver
  jpa:
    hibernate:
      ddl-auto: validate
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        show_sql: false
        format_sql: true
        jdbc:
          lob:
            non_contextual_creation: true
  # Flyway 数据库迁移配置
  flyway:
    enabled: true
    locations: classpath:db/migration
    baseline-on-migrate: true
    validate-on-migrate: true
    clean-disabled: true
    # 生产环境推荐配置
    out-of-order: false
    ignore-missing-migrations: false
    ignore-future-migrations: true
  # 禁用 Spring Boot 的 SQL 初始化
  sql:
    init:
      mode: never
  redis:
    host: redis.ecommerce.svc.cluster.local
    port: 6379
    password: ${REDIS_PASSWORD:password}
    timeout: 2000
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 2
        max-wait: -1ms

server:
  port: 8080
  servlet:
    context-path: /api

eureka:
  client:
    service-url:
      defaultZone: http://service-registry:8761/eureka/
    register-with-eureka: true
    fetch-registry: true

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
  endpoint:
    health:
      show-details: always
      show-components: always
    # 添加 Flyway 健康检查
    flyway:
      enabled: true

logging:
  level:
    com.ecommerce.product: INFO
    org.hibernate.SQL: WARN
    org.springframework.cache: TRACE
    # 添加 Flyway 日志级别
    org.flywaydb: INFO
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"

springdoc:
  api-docs:
    path: /v3/api-docs
  swagger-ui:
    path: /swagger-ui.html
    operations-sorter: method