application.yml 3.11 KB
spring:
  application:
    name: notification-service
  profiles:
    active: production
  datasource:
    url: jdbc:postgresql://postgresql-service.ecommerce.svc.cluster.local:5432/ecommerce_notifications
    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-ignored-migrations: false
    ignore-pending-migrations: false
    # 表名配置
    table: flyway_schema_history
    # 连接配置
    connect-retries: 3
    init-sqls: SET TIME ZONE 'UTC'
  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.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

# SMS Configuration
sms:
  provider: ${SMS_PROVIDER:twilio} # twilio, aws_sns, simulation
  twilio:
    account-sid: ${TWILIO_ACCOUNT_SID:default-sid}
    auth-token: ${TWILIO_AUTH_TOKEN:default-token}
    phone-number: ${TWILIO_PHONE_NUMBER:+1234567890}
  aws:
    sns:
      region: ${AWS_SNS_REGION:us-east-1}

# FCM Configuration
fcm:
  server-key: ${FCM_SERVER_KEY:default-key}
  url: ${FCM_URL:https://fcm.googleapis.com/fcm/send}
  service-account-file: ${FCM_SERVICE_ACCOUNT_FILE:firebase-service-account.json}
  database-url: ${FCM_DATABASE_URL:https://your-project-id.firebaseio.com}

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

logging:
  level:
    com.ecommerce.notification: INFO
    org.springframework.amqp: WARN
    org.hibernate.SQL: WARN
    org.springframework.mail: WARN
    org.flywaydb: INFO  # 添加 Flyway 日志级别
  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