データベース管理/監視


各部門のデータベース接続、および大量のデータベーステーブルについて、データベースのテーブル設計、フィールドの意味を理解したいと思います.navicateではなく、ドキュメントまたはビジュアル化インタフェースでリアルタイムで動的に表示したいと思っています.2つのオープンソースプロジェクトをお勧めします.
一:cn.smallbun.screwは表示しやすいhtmlドキュメントを生成する:参照ドキュメント.
1:POM jarパッケージ参照

    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.3.3.RELEASEversion>
        <relativePath/> 
    parent>
    <groupId>com.example.zdpgroupId>
    <artifactId>practiceartifactId>
    <version>0.0.1-SNAPSHOTversion>
    <name>practicename>
    <description>Demo project for Spring Bootdescription>

    <properties>
        <java.version>1.8java.version>
        <lastVersion>1.0.4lastVersion>
    properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>
        <dependency>
            <groupId>cn.smallbun.screwgroupId>
            <artifactId>screw-coreartifactId>
            <version>${lastVersion}version>
        dependency>
    

       
        <dependency>
            <groupId>org.projectlombokgroupId>
            <artifactId>lombokartifactId>
            <optional>trueoptional>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-testartifactId>
            <scope>testscope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintagegroupId>
                    <artifactId>junit-vintage-engineartifactId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>com.zaxxergroupId>
            <artifactId>HikariCPartifactId>
            <version>3.4.5version>
        dependency>
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>8.0.20version>
        dependency>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-thymeleafartifactId>
        dependency>
    dependencies>

2、コード例
package com.example.zdp.practice.config;

import cn.smallbun.screw.core.Configuration;
import cn.smallbun.screw.core.engine.EngineConfig;
import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType;
import cn.smallbun.screw.core.execute.DocumentationExecute;
import cn.smallbun.screw.core.process.ProcessConfig;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;
import java.util.ArrayList;

/**
 * @ClassName ScrewConfig
 * @Author dongping
 * @Date 2020/8/18 16:12
 * @Description ScrewConfig
 * @Version 1.0
 */
@Component
public class ScrewConfig {
    public static void main(String[] args) {

        new ScrewConfig().documentGeneration("a","");
    }
    /**
     *     
     */
     public void  documentGeneration(String url,String name) {
        //   
        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        hikariConfig.setJdbcUrl("jdbc:mysql://");
        hikariConfig.setUsername("root");
        hikariConfig.setPassword("");
        //      tables remarks  
        hikariConfig.addDataSourceProperty("useInformationSchema", "true");
        hikariConfig.setMinimumIdle(2);
        hikariConfig.setMaximumPoolSize(5);
        DataSource dataSource = new HikariDataSource(hikariConfig);
       /*  String staticPath = this.getClass().getClassLoader().getResource("static").getFile();
         System.out.println(staticPath);*/
        //    
        EngineConfig engineConfig = EngineConfig.builder()
                //      
                .fileOutputDir(url)
                //    
                .openOutputDir(true)
                //    
                .fileType(EngineFileType.HTML)
                //      
                .produceType(EngineTemplateType.freemarker)
                //       
                .fileName(name).build();

        //   
        ArrayList<String> ignoreTableName = new ArrayList<>();
        ignoreTableName.add("test_user");
        ignoreTableName.add("test_group");
        //     
        ArrayList<String> ignorePrefix = new ArrayList<>();
        ignorePrefix.add("test_");
        //     
        ArrayList<String> ignoreSuffix = new ArrayList<>();
        ignoreSuffix.add("_test");
        ProcessConfig processConfig = ProcessConfig.builder()
                //      、      、     、      ,      ,      、        
                //         
                .designatedTableName(new ArrayList<>())
                //       
                .designatedTablePrefix(new ArrayList<>())
                //       
                .designatedTableSuffix(new ArrayList<>())
                //    
                .ignoreTableName(ignoreTableName)
                //     
                .ignoreTablePrefix(ignorePrefix)
                //     
                .ignoreTableSuffix(ignoreSuffix).build();
        //  
        Configuration config = Configuration.builder()
                //  
                .version("1.0.0")
                //  
                .description("         ")
                //   
                .dataSource(dataSource)
                //    
                .engineConfig(engineConfig)
                //    
                .produceConfig(processConfig)
                .build();
        //    
        new DocumentationExecute(config).execute();
    }
}


2つの可視化インタフェースは、オープンソースプロジェクトのアドレスを表示する.
プロジェクトをjarパッケージとして私服に投げつけるか、ローカル倉庫maven installコマンドにパッケージ化し、springbootプロジェクトを新たに開始してjarパッケージを導入し、簡単なデータベースソース構成でフロントエンドの直接表示を実現します.
pom jarパッケージの導入
<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0modelVersion>
	<groupId>com.zyplayergroupId>
	<artifactId>zyplayer-doc-db-demoartifactId>
	<packaging>jarpackaging>
	<version>0.0.1-SNAPSHOTversion>

	<parent>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-parentartifactId>
		<version>1.5.9.RELEASEversion>
	parent>

	<dependencies>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-webartifactId>
		dependency>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-jta-atomikosartifactId>
		dependency>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-jdbcartifactId>
		dependency>
		<dependency>
			<groupId>commons-langgroupId>
			<artifactId>commons-langartifactId>
			<version>2.6version>
		dependency>
		<dependency>
			<groupId>commons-logginggroupId>
			<artifactId>commons-loggingartifactId>
			<version>1.2version>
		dependency>
		<dependency>
			<groupId>com.alibabagroupId>
			<artifactId>druidartifactId>
			<version>1.0.10version>
		dependency>
		<dependency>
			<groupId>mysqlgroupId>
			<artifactId>mysql-connector-javaartifactId>
			<version>5.1.26version>
		dependency>
		<dependency>
			<groupId>net.sourceforge.jtdsgroupId>
			<artifactId>jtdsartifactId>
			<version>1.3.0version>
		dependency>
		<dependency>
			<groupId>org.mybatisgroupId>
			<artifactId>mybatisartifactId>
			<version>3.4.6version>
		dependency>
		
		<dependency>
			<groupId>com.zyplayergroupId>
			<artifactId>zyplayer-doc-dbartifactId>
			<version>1.0.1-SNAPSHOTversion>
		dependency>
	dependencies>
project>


コードの例
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jta.atomikos.AtomikosDataSourceBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * mybatis     ,   mysql sqlsever        
 * 
 */
@Configuration
public class MybatisConfig {

	/**
	 * mysql     
	 */
	@Configuration
	@EnableTransactionManagement
	static class UserInfoMybatisDbConfig {

		@Value("${mysql.datasource.driverClassName}")
		private String driverClassName;
		@Value("${mysql.datasource.url}")
		private String datasourceUrl;
		@Value("${mysql.datasource.username}")
		private String datasourceUsername;
		@Value("${mysql.datasource.password}")
		private String datasourcePassword;

		@Primary
		@Bean(name = "userInfoDatasource")
		public DataSource userInfoDatasource() {
			Properties xaProperties = new Properties();
			xaProperties.setProperty("driverClassName", driverClassName);
			xaProperties.setProperty("url", datasourceUrl);
			xaProperties.setProperty("username", datasourceUsername);
			xaProperties.setProperty("password", datasourcePassword);
			xaProperties.setProperty("maxActive", "500");
			xaProperties.setProperty("testOnBorrow", "true");
			xaProperties.setProperty("testWhileIdle", "true");
			xaProperties.setProperty("validationQuery", "select 'x'");

			AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
			xaDataSource.setXaProperties(xaProperties);
			xaDataSource.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
			xaDataSource.setUniqueResourceName("userInfoDatasource");
			xaDataSource.setMaxPoolSize(500);
			xaDataSource.setMinPoolSize(1);
			xaDataSource.setMaxLifetime(60);
			return xaDataSource;
		}

		@Primary
		@Bean(name = "userInfoSqlSessionFactory")
		public SqlSessionFactoryBean userInfoSqlSessionFactory() throws Exception {
			SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
			sqlSessionFactoryBean.setDataSource(userInfoDatasource());
			return sqlSessionFactoryBean;
		}
	}
package com.zyplayer.doc.db.demo.config;

import java.util.LinkedList;
import java.util.List;

import javax.annotation.Resource;
import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.zyplayer.doc.db.framework.configuration.EnableDocDb;
import com.zyplayer.doc.db.framework.db.bean.DatabaseRegistrationBean;

/**
 * bean         
 * 
 */
@Component
@EnableDocDb//       
@Configuration
public class WebMvcConfig {
	
	// mysql     
	@Resource(name = "userInfoDatasource")
	private DataSource userInfoDatasource;
	// sqlsever     
/*	@Resource(name = "orderInfoDatasource")
	private DataSource orderInfoDatasource;*/

	/**
	 *        bean
	 * 
	 * @return
	 */
	@Bean
	public DatabaseRegistrationBean databaseRegistrationBean() {
		DatabaseRegistrationBean bean = new DatabaseRegistrationBean();
		List<DataSource> dataSourceList = new LinkedList();
		dataSourceList.add(userInfoDatasource);
//		dataSourceList.add(orderInfoDatasource);
		bean.setDataSourceList(dataSourceList);
		return bean;
	}
}


application.propertiesのプロファイル
mysql.datasource.driverClassName=com.mysql.jdbc.Driver
mysql.datasource.url=jdbc:mysql://useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true
mysql.datasource.username=root
mysql.datasource.password=***

demoアドレスリンク