application.yml 3.2 KB
spring:
  application:
    name: user-service
  profiles:
    active: production
  datasource:
    url: jdbc:postgresql://postgresql-service:5432/ecommerce_users
    username: ${SPRING_DATASOURCE_USERNAME:admin}
    password: ${SPRING_DATASOURCE_PASSWORD}
    driver-class-name: org.postgresql.Driver
    hikari:
      maximum-pool-size: 10
      minimum-idle: 2
      connection-timeout: 30000
      idle-timeout: 600000
      max-lifetime: 1800000
  jpa:
    hibernate:
      ddl-auto: validate
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    show-sql: false
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
        format_sql: true
        jdbc:
          batch_size: 20
          order_inserts: true
          order_updates: true
  redis:
    host: redis-service
    port: 6379
    password: ${SPRING_REDIS_PASSWORD}
    timeout: 2000
    lettuce:
      pool:
        max-active: 10
        max-idle: 5
        min-idle: 2
        max-wait: 1000
  # ==================== Flyway 数据库迁移配置 ====================
  flyway:
    enabled: true
    validate-on-migrate: true
    baseline-on-migrate: true
    baseline-version: 1
    locations: classpath:db/migration
    schemas: public
    table: flyway_schema_history
    clean-disabled: true
    out-of-order: false
    ignore-missing-migrations: false
    ignore-future-migrations: true
    # 如果数据库不存在时自动创建(可选)
    # create-schemas: true
    # 初始化SQL(可选)
    # init-sqls: CREATE SCHEMA IF NOT EXISTS public;

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

eureka:
  client:
    enabled: false
    register-with-eureka: false
    fetch-registry: false

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
    enabled-by-default: false
  endpoint:
    health:
      enabled: true
      show-details: always
      probes:
        enabled: true
    info:
      enabled: true
    metrics:
      enabled: true
    prometheus:
      enabled: true
  health:
    db:
      enabled: true
    redis:
      enabled: true
    # Flyway 健康检查
    flyway:
      enabled: true

logging:
  level:
    com.ecommerce.user: DEBUG
    org.hibernate.SQL: WARN
    org.hibernate.type.descriptor.sql.BasicBinder: WARN
    org.springframework.security: WARN
    # Flyway 日志配置
    org.flywaydb: INFO
  pattern:
    console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"

jwt:
  secret: ${JWT_SECRET}
  expiration: ${JWT_EXPIRATION:86400000}
  refresh-expiration: 2592000000

app:
  security:
    password:
      min-length: ${PASSWORD_MIN_LENGTH:8}
      max-length: ${PASSWORD_MAX_LENGTH:128}
    login:
      max-attempts: ${MAX_LOGIN_ATTEMPTS:5}
      lockout-duration: ${ACCOUNT_LOCKOUT_DURATION:900000}
    verification:
      email: ${REQUIRE_EMAIL_VERIFICATION:true}
      phone: ${REQUIRE_PHONE_VERIFICATION:false}
    bcrypt-strength: ${BCRYPT_STRENGTH:12}
    session-timeout: ${SESSION_TIMEOUT:1800}
    csrf-protection: ${ENABLE_CSRF_PROTECTION:true}

notification:
  service-url: ${NOTIFICATION_SERVICE_URL:http://notification-service:8080}
  send-welcome-email: ${SEND_WELCOME_EMAIL:true}