1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        一鍵生成數(shù)據(jù)庫文檔的大利器!

        共 5685字,需瀏覽 12分鐘

         ·

        2022-04-11 16:21

        1

        簡介


        screw (螺絲釘) ,一款簡潔好用的數(shù)據(jù)庫表結(jié)構(gòu)文檔工具,支持MySQL/MariaDB/SqlServer/Oracle/PostgreSQL/TIDB/CacheDB 數(shù)據(jù)庫。



        2

        特點

        ?

        • 簡潔、輕量、設(shè)計良好

        • 多數(shù)據(jù)庫支持

        • 多種格式文檔

        • 靈活擴展

        • 支持自定義模板



        3

        文檔生成支持


        • html

        • word

        • markdown



        4

        文檔截圖


        • html




        • word



        • markdwon





        5

        使用方式


        普通方式


        • 引入依賴


        <dependency>
        ????<groupId>cn.smallbun.screwgroupId>

        ????<artifactId>screw-coreartifactId>
        ????<version>${lastVersion}version>
        dependency>


        • 編寫代碼


        /**
        ?* 文檔生成
        ?*/

        void?documentGeneration() {
        ???//數(shù)據(jù)源
        ???HikariConfig hikariConfig = new?HikariConfig();
        ???hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ???hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/database");
        ???hikariConfig.setUsername("root");
        ???hikariConfig.setPassword("password");
        ???//設(shè)置可以獲取tables remarks信息
        ???hikariConfig.addDataSourceProperty("useInformationSchema", "true");
        ???hikariConfig.setMinimumIdle(2);
        ???hikariConfig.setMaximumPoolSize(5);
        ???DataSource dataSource = new?HikariDataSource(hikariConfig);
        ???//生成配置
        ???EngineConfig engineConfig = EngineConfig.builder()
        ?????????//生成文件路徑
        ?????????.fileOutputDir(fileOutputDir)
        ?????????//打開目錄
        ?????????.openOutputDir(true)
        ?????????//文件類型
        ?????????.fileType(EngineFileType.HTML)
        ?????????//生成模板實現(xiàn)
        ?????????.produceType(EngineTemplateType.freemarker)
        ?????????//自定義文件名稱
        ?????????.fileName("自定義文件名稱").build();

        ???//忽略表
        ???ArrayList ignoreTableName = new?ArrayList<>();
        ???ignoreTableName.add("test_user");
        ???ignoreTableName.add("test_group");
        ???//忽略表前綴
        ???ArrayList ignorePrefix = new?ArrayList<>();
        ???ignorePrefix.add("test_");
        ???//忽略表后綴
        ???ArrayList ignoreSuffix = new?ArrayList<>();
        ???ignoreSuffix.add("_test");
        ???ProcessConfig processConfig = ProcessConfig.builder()
        ?????????//指定生成邏輯、當存在指定表、指定表前綴、指定表后綴時,將生成指定表,其余表不生成、并跳過忽略表配置
        ???//根據(jù)名稱指定表生成
        ???.designatedTableName(new?ArrayList<>())
        ???//根據(jù)表前綴生成
        ???.designatedTablePrefix(new?ArrayList<>())
        ???//根據(jù)表后綴生成
        ???.designatedTableSuffix(new?ArrayList<>())
        ?????????//忽略表名
        ?????????.ignoreTableName(ignoreTableName)
        ?????????//忽略表前綴
        ?????????.ignoreTablePrefix(ignorePrefix)
        ?????????//忽略表后綴
        ?????????.ignoreTableSuffix(ignoreSuffix).build();
        ???//配置
        ???Configuration config = Configuration.builder()
        ?????????//版本
        ?????????.version("1.0.0")
        ?????????//描述
        ?????????.description("數(shù)據(jù)庫設(shè)計文檔生成")
        ?????????//數(shù)據(jù)源
        ?????????.dataSource(dataSource)
        ?????????//生成配置
        ?????????.engineConfig(engineConfig)
        ?????????//生成配置
        ?????????.produceConfig(processConfig)
        ?????????.build();
        ???//執(zhí)行生成
        ???new?DocumentationExecute(config).execute();
        }


        Maven 插件


        <build>
        ????<plugins>
        ????????<plugin>
        ????????????<groupId>cn.smallbun.screwgroupId>

        ????????????<artifactId>screw-maven-pluginartifactId>
        ????????????<version>${lastVersion}version>
        ????????????<dependencies>
        ????????????????
        ????????????????<dependency>
        ????????????????????<groupId>com.zaxxergroupId>
        ????????????????????<artifactId>HikariCPartifactId>
        ????????????????????<version>3.4.5version>
        ????????????????dependency>
        ????????????????
        ????????????????<dependency>
        ????????????????????<groupId>mysqlgroupId>
        ????????????????????<artifactId>mysql-connector-javaartifactId>
        ????????????????????<version>8.0.20version>
        ????????????????dependency>
        ????????????dependencies>
        ????????????<configuration>
        ????????????????
        ????????????????<username>rootusername>
        ????????????????
        ????????????????<password>passwordpassword>
        ????????????????
        ????????????????<driverClassName>com.mysql.cj.jdbc.DriverdriverClassName>
        ????????????????
        ????????????????<jdbcUrl>jdbc:mysql://127.0.0.1:3306/xxxxjdbcUrl>
        ????????????????
        ????????????????<fileType>HTMLfileType>
        ????????????????
        ????????????????<openOutputDir>falseopenOutputDir>
        ????????????????
        ????????????????<produceType>freemarkerproduceType>
        ????????????????
        ????????????????<fileName>測試文檔名稱fileName>
        ????????????????
        ????????????????<description>數(shù)據(jù)庫文檔生成description>
        ????????????????
        ????????????????<version>${project.version}version>
        ????????????????
        ????????????????<title>數(shù)據(jù)庫文檔title>
        ????????????configuration>
        ????????????<executions>
        ????????????????<execution>
        ????????????????????<phase>compilephase>
        ????????????????????<goals>
        ????????????????????????<goal>rungoal>
        ????????????????????goals>
        ????????????????execution>
        ????????????executions>
        ????????plugin>
        ????plugins>
        build>


        ?

        6

        擴展模塊

        ?

        pojo生成功能


        功能簡介


        pojo生成功能是基于screw延伸出的擴展模塊,目前處于初步開發(fā)的狀態(tài)。在日常的開發(fā)中,經(jīng)過需求分析、建模之后,往往會先在數(shù)據(jù)庫中建表,其次在進行代碼的開發(fā)。


        那么pojo生成功能在這個階段就可以幫助大家節(jié)省一些重復勞動了。使用pojo生成功能可以直接根據(jù)數(shù)據(jù)庫生成對應(yīng)的java pojo對象。這樣后續(xù)的修改,開發(fā)都會很方便。


        數(shù)據(jù)庫支持


        • MySQL


        使用方式


        • 引入依賴


        <dependency>
        ????<groupId>cn.smallbun.screwgroupId>

        ????<artifactId>screw-extensionartifactId>
        ????<version>${lastVersion}version>
        dependency>


        • 編寫代碼


        /**
        ?* pojo生成
        ?*/

        void?pojoGeneration()?{
        ????//數(shù)據(jù)源
        ????HikariConfig hikariConfig = new?HikariConfig();
        ????hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ????hikariConfig.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/screw");
        ????hikariConfig.setUsername("screw");
        ????hikariConfig.setPassword("screw");
        ????//設(shè)置可以獲取tables remarks信息
        ????hikariConfig.addDataSourceProperty("useInformationSchema", "true");
        ????hikariConfig.setMinimumIdle(2);
        ????hikariConfig.setMaximumPoolSize(5);
        ????DataSource dataSource = new?HikariDataSource(hikariConfig);

        ????ProcessConfig processConfig = ProcessConfig.builder()
        ????????//指定生成邏輯、當存在指定表、指定表前綴、指定表后綴時,將生成指定表,其余表不生成、并跳過忽略表配置
        ????????//根據(jù)名稱指定表生成
        ????????.designatedTableName(new?ArrayList<>())
        ????????//根據(jù)表前綴生成
        ????????.designatedTablePrefix(new?ArrayList<>())
        ????????//根據(jù)表后綴生成
        ????????.designatedTableSuffix(new?ArrayList<>()).build();

        ????//設(shè)置生成pojo相關(guān)配置
        ????PojoConfiguration config = new?PojoConfiguration();
        ????//設(shè)置文件存放路徑
        ????config.setPath("/cn/smallbun/screw/");
        ????//設(shè)置包名
        ????config.setPackageName("cn.smallbun.screw");
        ????//設(shè)置是否使用lombok
        ????config.setUseLombok(false);
        ????//設(shè)置數(shù)據(jù)源
        ????config.setDataSource(dataSource);
        ????//設(shè)置命名策略
        ????config.setNameStrategy(new?HumpNameStrategy());
        ????//設(shè)置表過濾邏輯
        ????config.setProcessConfig(processConfig);
        ????//執(zhí)行生成
        ????new?PojoExecute(config).execute();
        }



        7

        常見問題


        1.生成后文檔亂碼?


        MySQL:URL加入?characterEncoding=UTF-8。


        2.Caused by: java.lang.NoSuchFieldError: VERSION_2_3_30?


        檢查項目freemarker依賴,這是由于版本過低造成的,升級版本為2.3.30即可。


        3.java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.getSchema()Ljava/lang/String;


        這是因為oracle驅(qū)動版本過低造成的,刪除或屏蔽目前驅(qū)動版本,驅(qū)動添加升級為以下版本:


        <dependency>
        ???<groupId>com.oracle.ojdbcgroupId>

        ???<artifactId>ojdbc8artifactId>
        ???<version>19.3.0.0version>
        dependency>
        <dependency>
        ???<groupId>cn.easyprojectgroupId>
        ???<artifactId>orai18nartifactId>
        ???<version>12.1.0.2.0version>
        dependency>


        4.MySQL數(shù)據(jù)庫表和列字段有說明、生成文檔沒有說明?


        URL鏈接加入useInformationSchema=true即可。


        5.java.lang.AbstractMethodError: com.mysql.jdbc.JDBC4Connection.getSchema()Ljava/lang/String;


        這是因為mysql驅(qū)動版本過低造成的,升級mysql驅(qū)動版本為最新即可。


        項目地址


        Gitee:https://gitee.com/leshalv/screw



        最近熬夜給大家準備了非常全的一套Java一線大廠面試題。全面覆蓋BATJ等一線互聯(lián)網(wǎng)公司的面試題及解答,由BAT一線互聯(lián)網(wǎng)公司大牛帶你深度剖析面試題背后的原理,不僅授你以魚,更授你以漁,為你面試掃除一切障礙。



        資源,怎么領(lǐng)取?


        掃二維碼,加我微信,備注:面試題


        一定要備注:面試題,不要急哦,工作忙完后就會通過!




        瀏覽 70
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            欧亚一级片 | 中文字幕在线观看第一页2019 | 欧美淫色网站 | 操逼黄色一级网站 | 禁亲女爽浪骚乱h小喜 | 黄色一级视频免费看 | 出差的丰满新婚少妇 | 偷拍一区二区三区 | 欧美组合两个男的一个唱饶舌 | 好湿好紧好多水好 |