Code Monkey home page Code Monkey logo

nacos-datasource-plugin-pg's Introduction

Nacos 从 2.2.0 版本开始,可通过 SPI 机制注入多数据源实现插件,并在引入对应数据源实现后,便可在 Nacos 启动时通过读取 application.properties 配置文件中 spring.datasource.platform 配置项选择加载对应多数据源插件.

Nacos 插件化实现

Nacos 官方默认实现 MySQL、Derby ,其他类型数据库接入需要参考下文自己扩展。

自定义 PostgreSQL 插件

1. 添加 postgresql 插件

依赖已上传 maven **仓库,请勿使用阿里云代理

<dependency>
	<groupId>com.pig4cloud.plugin</groupId>
	<artifactId>nacos-datasource-plugin-pg</artifactId>
	<version>0.0.2</version>
</dependency>

<dependency>
	<groupId>org.postgresql</groupId>
	<artifactId>postgresql</artifactId>
</dependency>

2. 导入 nacos postgresql 数据库脚本

./sql/nacos-pg.sql

3. 配置 nacos 数据源链接信息

db:
  num: 1
  url:
    0: jdbc:postgresql://172.27.0.5:5432/pigxx_config
  user:
    0: postgres
  password:
    0: 123456
  pool:
    config:
      driver-class-name: org.postgresql.Driver

4. 指定 nacos 数据源平台

spring:
  datasource:
    platform: postgresql

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.