application.yml 3.74 KB
spring:
  application:
    name: notification-service
  profiles:
    active: prod
  datasource:
    url: jdbc:postgresql://postgresql-service:5432/ecommerce_notifications
    username: ${DB_USERNAME:admin}
    password: ${DB_PASSWORD:postgres123}
    driver-class-name: org.postgresql.Driver
    # 添加 HikariCP 连接池配置
    hikari:
      connection-timeout: 30000
      maximum-pool-size: 10
      minimum-idle: 2
      idle-timeout: 600000
      max-lifetime: 1800000
      connection-test-query: SELECT 1
  
  # ========== Flyway 数据库迁移配置 ==========
  flyway:
    enabled: true
    locations: classpath:db/migration
    baseline-on-migrate: true
    validate-on-migrate: true
    # 生产环境配置
    out-of-order: false
    # 验证规则
    ignore-missing-migrations: true
    ignore-future-migrations: true
    ignore-ignored-migrations: true
    ignore-pending-migrations: true
    # 修复配置
    repair-on-migrate: true
    validate-migration-naming: true
    placeholder-replacement: false
    # 添加基线配置
    baseline-version: 0
    baseline-description: "Base migration"
    # 表名配置
    table: flyway_schema_history_notifications
    # 生产环境推荐禁用清理(只保留这一个)
    clean-disabled: true
  # =========================================
  
  jpa:
    hibernate:
      ddl-auto: validate
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        show_sql: false
        format_sql: true
        jdbc:
          lob:
            non_contextual_creation: true
        # 移除有问题的配置
        check_nullability: false
  
  # 禁用 Spring Boot 的 SQL 初始化
  sql:
    init:
      mode: never
  
  mail:
    host: ${SMTP_HOST:smtp.gmail.com}
    port: ${SMTP_PORT:587}
    username: ${SMTP_USERNAME:your-email@gmail.com}
    password: ${SMTP_PASSWORD:your-app-password}
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
        transport:
          protocol: smtp
        debug: false
  
  rabbitmq:
    host: rabbitmq
    port: 5672
    username: ${RABBITMQ_USERNAME:admin}
    password: ${RABBITMQ_PASSWORD:rabbitmq123}
    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

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus,flyway
      # 添加管理端点路径
      base-path: /management
  endpoint:
    health:
      show-details: when_authorized
      show-components: when_authorized
      # 添加健康检查组
      group:
        custom:
          include: db,rabbitmq,mail
    # Flyway 端点
    flyway:
      enabled: true
    # 指标端点
    metrics:
      enabled: true

logging:
  level:
    com.ecommerce.notification: INFO
    org.springframework.amqp: WARN
    org.hibernate.SQL: WARN
    org.springframework.mail: WARN
    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

# Scheduled tasks for processing pending notifications
scheduling:
  enabled: true

# 应用自定义配置
app:
  database:
    lenient-schema-validation: true
    auto-repair-missing-columns: false
  notification:
    # 通知配置
    email-enabled: ${NOTIFICATION_EMAIL_ENABLED:false}
    sms-enabled: ${NOTIFICATION_SMS_ENABLED:false}
    push-enabled: ${NOTIFICATION_PUSH_ENABLED:false}
    # 重试配置
    max-retry-attempts: 3
    retry-delay-seconds: 60
    # 批量处理配置
    batch-size: 100