configmap.yaml 3.49 KB
apiVersion: v1
kind: ConfigMap
metadata:
  name: inventory-service-config
  namespace: ecommerce
  labels:
    app: inventory-service
data:
  application.yml: |
    server:
      port: 8080
      servlet:
        context-path: /api/inventory
    
    spring:
      application:
        name: inventory-service
      profiles:
        active: production
      
      # PostgreSQL 数据库配置
      datasource:
        url: jdbc:postgresql://postgresql-service:5432/ecommerce
        username: admin
        password: ${POSTGRES_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 配置 - 修改为 update 来自动创建表
      jpa:
        hibernate:
          ddl-auto: update
          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
      
      # MongoDB 配置
      data:
        mongodb:
          uri: mongodb://admin:${MONGO_PASSWORD}@mongodb-service:27017/ecommerce?authSource=admin
          database: ecommerce
          auto-index-creation: true
      
      # Redis 配置
      redis:
        host: redis-service
        port: 6379
        password: ${REDIS_PASSWORD}
        timeout: 2000
        lettuce:
          pool:
            max-active: 10
            max-idle: 5
            min-idle: 2
            max-wait: 1000
      
      # RabbitMQ 配置 - 使用 admin 用户
      rabbitmq:
        host: rabbitmq-service
        port: 5672
        username: admin
        password: ${RABBITMQ_PASSWORD}
        virtual-host: /
        # 连接池配置
        connection-timeout: 5000
        template:
          retry:
            enabled: true
            initial-interval: 1000
            max-attempts: 3
            max-interval: 10000
            multiplier: 2.0
        listener:
          simple:
            retry:
              enabled: true
              initial-interval: 1000
              max-attempts: 3
              max-interval: 10000
              multiplier: 2.0
            auto-startup: true
            acknowledge-mode: auto
            prefetch: 1
            default-requeue-rejected: false
    
    # 禁用 Eureka 服务发现
    eureka:
      client:
        enabled: false
        register-with-eureka: false
        fetch-registry: false
      instance:
        enabled: false
    
    # 缓存配置
    cache:
      type: redis
      redis:
        time-to-live: 1800000
        cache-null-values: false
    
    # 外部服务配置
    service:
      product:
        url: http://product-service:8080
      order:
        url: http://order-service:8080
    
    # 日志配置
    logging:
      level:
        com.ecommerce.inventoryservice: DEBUG
        org.hibernate.SQL: WARN
        org.hibernate.type.descriptor.sql.BasicBinder: WARN
        org.springframework.data.mongodb.core: WARN
        org.springframework.amqp: WARN
    
    # Actuator 配置
    management:
      endpoints:
        web:
          exposure:
            include: health,info,metrics,prometheus
      endpoint:
        health:
          show-details: always
          probes:
            enabled: true