GithubHelp home page GithubHelp logo

databases-tools's Introduction

数据库字典导出工具

项目框架: SpringBoot + Mybatis

模板引擎: FreeMarker

XML解析: xstream解析xml文件

数据库: MySQL

基本思路

首先根据数据库的schema信息查询出所有的数据库表的集合,之后迭代表集合,再查询出每张数据表的列字段信息集合列表,之后通过封装成javaBean对象,再使用freemarker模板引擎导出HTML文件即可。

使用指南:

1、配置文件说明:

application.properties文件:配置数据库连接信息和schema名称以及导出的路径

static/table-info.xml文件:配置导出的表信息

2、application.properties配置信息:
spring.datasource.url=jdbc\:mysql\://127.0.0.1\:3306/lmstest?characterEncoding\=utf8
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

mybatis.check-config-location=true
mybatis.config-location=classpath:mybatis-config.xml

#user config
com.feizi.schema.name=lmstest

#export path
com.feizi.export.folder=F:/htmlTemplate

需要注意的是: 导出路径的文件夹需要提前创建好,否则会报错,不过可以自行改造

3、导出表信息配置(table-info.xml):

  1. 导出所有表

<module name="所有模块" type="all"/>

  1. type类型为prefix,表示按照指定的table类型导出,比如eaxm前缀,则表示导出考试模块

<module name="爱问模块" type="prefix" table="ask"/>

  1. type类型为table,表示按照指定的table表名导出,比如执行user_info,user_config

<module name="考试模块" type="table" table="exam_info,user_info"/>

4、因为只是类似于一个工具类,只需要跑一个main方法即可,所以其实使用SpringBoot框架算是多余了,这里通过跑测试用例导出

导出步骤:

test/resources里面也需要拷贝相应的配置文件

执行com.feizi.controller.ExportDictionaryControllerTest测试用例的testExportDictionary()方法即可。

5、执行效果:

1

databases-tools's People

Stargazers

 avatar

Watchers

 avatar

Forkers

xinyi-lt

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.