How to Add a Custom DM8 Database Plugin to Nacos 2.2

Starting with Nacos 2.2.0, this guide shows how to create a custom DM8 database plugin via the SPI mechanism, add Maven dependencies, import the required scripts, configure connection settings and set the platform property, enabling Nacos to persist data in a DM8 database.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
How to Add a Custom DM8 Database Plugin to Nacos 2.2

From version 2.2.0, Nacos supports injecting multiple data sources through the SPI mechanism, allowing plugins to be loaded by setting the spring.datasource.platform property in application.properties.

By default Nacos implements MySQL and Derby; other databases require custom extensions.

Custom DM8 Plugin

1. Add DM8 database plugin

Dependencies are available in Maven Central; avoid using Alibaba Cloud mirrors.
<!-- Maven dependencies --><dependency>
    <groupId>com.pig4cloud.plugin</groupId>
    <artifactId>nacos-datasource-plugin-dm8</artifactId>
    <version>0.0.1</version>
</dependency>

<dependency>
    <groupId>com.dameng</groupId>
    <artifactId>DmJdbcDriver18</artifactId>
    <version>8.1.1.193</version>
</dependency>

2. Import Nacos DM8 database script

Create a tablespace named nacos in the DM8 management tool and import the provided SQL script.

3. Configure Nacos datasource connection

db:
  num: 1
  url:
    0: jdbc:dm://172.27.0.5:5236/nacos
  user: nacos
  password: nacos@123
  pool:
    config:
      driver-class-name: dm.jdbc.driver.DmDriver

4. Set database platform

spring:
  datasource:
    platform: dameng
Source code repository: https://github.com/pig-mesh/nacos-datasource-plugin-dm8
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackenddatabasepluginNacosDM8
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.