application.yml 2.5 KB
spring:
  application:
    name: order-service
  profiles:
    active: prod
  datasource:
    url: jdbc:postgresql://postgresql-service.ecommerce.svc.cluster.local:5432/ecommerce_orders
    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: true  # 暂时设为 true 便于调试
        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
    # 重新部署时清理已应用的迁移(可选)
    clean-on-validation-error: true  # 添加这个
    # 表名配置
    table: flyway_schema_history
    # 迁移时占位符替换
    placeholders:
      app-name: order-service
    # 迁移失败时的行为
    ignore-migration-patterns: '*:pending'
    # 在迁移前验证迁移文件
    validate-migration-naming: true
  rabbitmq:
    host: rabbitmq-service.ecommerce.svc.cluster.local
    port: 5672
    username: ${RABBITMQ_USERNAME:guest}
    password: ${RABBITMQ_PASSWORD:guest}
    virtual-host: /
    connection-timeout: 5000

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

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

feign:
  client:
    config:
      default:
        connectTimeout: 5000
        readTimeout: 10000
        loggerLevel: basic
  circuitbreaker:
    enabled: 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.order: INFO
    org.springframework.amqp: WARN
    org.hibernate.SQL: DEBUG  # 暂时设为 DEBUG 便于查看 SQL
    org.hibernate.type.descriptor.sql.BasicBinder: TRACE  # 查看绑定参数
    feign: DEBUG
    # Flyway 日志配置
    org.flywaydb: DEBUG  # 设为 DEBUG 查看迁移详情
    org.flywaydb.core: DEBUG
  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