您的位置:首页 > 科技 > IT业 > 合肥瑶海区疫情_网站建站公司哪家价钱合理_徐州关键词优化排名_网站关键词优化排名外包

合肥瑶海区疫情_网站建站公司哪家价钱合理_徐州关键词优化排名_网站关键词优化排名外包

2024/9/22 0:28:04 来源:https://blog.csdn.net/zwrlj527/article/details/142200936  浏览:    关键词:合肥瑶海区疫情_网站建站公司哪家价钱合理_徐州关键词优化排名_网站关键词优化排名外包
合肥瑶海区疫情_网站建站公司哪家价钱合理_徐州关键词优化排名_网站关键词优化排名外包

前言

       最近公司人员结构调整,被迫接受一位资深老哥哥的活,他也是悲催,太老实了,默默的干活老黄牛,不会叫。又没有山头,直接领导组长也是不给力。哎,哪里都有江湖,愿我码农儿女都能被善待!!!!
       今天要分享的是,搭建springboot项目,反向生成数据库表结构说明文档。


一、screw介绍

       不是大厂写的,是个人写的,但是不得不说,好使啊, 为爱发电。

二、使用步骤

1.新建一个空的springboot项目

       这个使用idea,选择springboot,下一步下一步就行。
我这里是maven项目,pom文件引入jar包。
我这里的整个pom.xml内容

<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.3.3</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.easylinkin</groupId><artifactId>my-screw</artifactId><version>0.0.1-SNAPSHOT</version><name>my-screw</name><description>my-screw</description><url/><licenses><license/></licenses><developers><developer/></developers><scm><connection/><developerConnection/><tag/><url/></scm><properties><java.version>17</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>cn.smallbun.screw</groupId><artifactId>screw-core</artifactId><version>1.0.5</version></dependency><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId></dependency><dependency><groupId>com.zaxxer</groupId><artifactId>HikariCP</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

2.生成文档的测试类

package com.easylinkin.myscrew;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.HikariDataSource;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;@Slf4j
@SpringBootTest
class MyScrewApplicationTests {//@Testvoid contextLoads() {}/*** 获取数据源配置*/@Testvoid generate() {log.info("开始生成数据库文档");String dbFilePath = "/Users/zwmac/work/ovu/数据库";// 生成文件配置EngineConfig engineConfig = EngineConfig.builder()// 生成文件路径,自己mac本地的地址,这里需要自己更换下路径.fileOutputDir(dbFilePath)// 打开目录.openOutputDir(false)// 文件类型 HTML/WORD/MD 三种格式.fileType(EngineFileType.WORD)// 生成模板实现.produceType(EngineTemplateType.freemarker).build();//数据库名称String[] dbNames = {"ovuhome"};for (String dbName : dbNames) {HikariDataSource hikariDataSource = new HikariDataSource();//设置数据库连接hikariDataSource.setJdbcUrl("jdbc:mysql://127.0.0.1:3306/" + dbName + "?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true");hikariDataSource.setUsername("root");hikariDataSource.setPassword("12345678");// 生成文档配置(包含以下自定义版本号、描述等配置连接)Configuration config = Configuration.builder()//文档版本号.version("1.0.1")//文档名称.description("公寓数据库设计文档")//数据源.dataSource(hikariDataSource)//生成引擎配置.engineConfig(engineConfig)//高级配置//.produceConfig(getProcessConfig()).build();// 执行生成new DocumentationExecute(config).execute();}log.info("生成数据库文档完成");}/*** 配置想要生成的表+ 配置想要忽略的表* @return 生成表配置*/public static ProcessConfig getProcessConfig(){// 忽略表名List<String> ignoreTableName = Arrays.asList("testa_testa","testb_testb");// 忽略表前缀List<String> ignorePrefix = Arrays.asList("testa","testb");// 忽略表后缀List<String> ignoreSuffix = Arrays.asList("_testa","_testb");return ProcessConfig.builder()//根据名称指定表生成 我需要生成所有表 这里暂时不设置.designatedTableName(new ArrayList<>())//根据表前缀生成 我需要生成所有表 这里暂时不设置.designatedTablePrefix(new ArrayList<>())//根据表后缀生成 我需要生成所有表 这里暂时不设置.designatedTableSuffix(new ArrayList<>())//忽略表名.ignoreTableName(ignoreTableName)//忽略表前缀.ignoreTablePrefix(ignorePrefix)//忽略表后缀.ignoreTableSuffix(ignoreSuffix).build();}}

       测试类运行,就不说了,自己摸索摸索。

3.生成的word文档效果

在这里插入图片描述


总结

       接手的活就是三无项目,无测试、无需求、无文档,只有代码。到我这已经是第五手了,山头注意真害人,还限制人发展啊。愿我们码农儿女都能凭技术吃饭,扎扎实实的,少些勾心斗角。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com