Files
iot-dc3/dc3-common/dc3-common-postgres
Vickey 50cf4dad62 fix(config): align auto-configuration classes and fix resource leaks for Spring Boot 4.x
Auto-configuration:
- Replace @Configuration with @AutoConfiguration on 21 classes listed
  in AutoConfiguration.imports (InitRunners, topic configs, DalConfig,
  MqttConfig, ThreadPoolConfig, RabbitConfig, ExchangeConfig, etc.)
- Add @AutoConfiguration to ExceptionConfig alongside @RestControllerAdvice

WebFlux fixes:
- Replace getServlet().getContextPath() with getReactive().getContextPath()
  in WebFilterConfig (servlet API in reactive context)
- Remove redundant @EnableWebFlux and @Slf4j from WebFluxConfig
- Replace deprecated customCodecs().registerWithDefaultConfig() with
  defaultCodecs().jacksonJsonEncoder/Decoder()

Driver lifecycle:
- Replace System.exit(1) in DriverRegisterServiceImpl with
  ServiceException to allow Spring graceful shutdown

Resource leaks:
- Wrap FileOutputStream in try-with-resources in DeviceServiceImpl
- Wrap BufferedWriter in try-with-resources in CmdUtil
- Rewrite X509Util.loadCertificateWithPassword with try-with-resources
  and remove dead if/else branches
2026-05-10 11:22:50 +08:00
..

DC3 Common Postgres

Overview

dc3-common-postgres is the shared PostgreSQL and MyBatis-Plus configuration module of the IoT DC3 platform. It auto-configures datasource, paging plugin, and common MyBatis utility support for all services that use PostgreSQL as their primary storage.

Module Information

  • Group ID: io.github.pnoker
  • Artifact ID: dc3-common-postgres
  • Version: 2026.5.5

Key Components

Component Purpose
MybatisPlusConfig Configures MybatisPlusInterceptor with pagination plugin; sets default enum type handler
MybatisUtil Utility methods for building MyBatis-Plus LambdaQueryWrapper conditions from query objects
ActivePostgresProfileConfig Profile-conditional config activation

Configuration Properties

Uses dynamic-datasource-spring-boot-starter for multi-datasource support:

spring:
  datasource:
    dynamic:
      datasource:
        master:
          url: jdbc:postgresql://${POSTGRES_HOST:dc3-postgres}:${POSTGRES_PORT:35432}/${POSTGRES_DB:dc3}?currentSchema=${POSTGRES_SCHEMA:dc3_manager}&...
          username: ${POSTGRES_USERNAME:dc3}
          password: ${POSTGRES_PASSWORD:dc3dc3dc3}

Schema Isolation

Each center service uses a separate Postgres schema via currentSchema in the JDBC URL:

Service Schema
dc3-center-auth dc3_auth
dc3-center-manager dc3_manager
dc3-center-data dc3_data

Build Instructions

mvn -s ../../.mvn/settings.xml clean package
  • dc3-common-manager, dc3-common-auth, dc3-common-data — Include this as a dependency for Postgres access
  • dc3-common-dal — Builds on top of this for shared DAL entities

License

Copyright 2016-present the IoT DC3 original author or authors.

Licensed under the GNU Affero General Public License v3.0 (AGPL 3.0)