抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

一些好用的文档工具

一、数据库文档生成:screw

1
2
3
简洁好用的数据库表结构文档工具

支持MySQL/MariaDB/SqlServer/Oracle/PostgreSQL/TIDB/CacheDB 数据库。

写数据库设计文档的时候可以用这个偷懒

官方开源地址

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

导入依赖:

1
2
3
4
5
6
<!--screw需要的依赖-->
<dependency>
<groupId>cn.smallbun.screw</groupId>
<artifactId>screw-core</artifactId>
<version>1.0.5</version>
</dependency>

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public static void main(String[] args){
new GeneralDoc().documentGeneration();
}
/**
* 文档生成
*/
private void documentGeneration() {
//数据源
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
hikariConfig.setJdbcUrl("jdbc:mysql://localhost:3306/mp?serverTimezone=UTC&zeroDateTimeBehavior=round&allowMultiQueries=true");
hikariConfig.setUsername("root");
hikariConfig.setPassword("zyy010907");
//设置可以获取tables remarks信息
hikariConfig.addDataSourceProperty("useInformationSchema", "true");
hikariConfig.setMinimumIdle(2);
hikariConfig.setMaximumPoolSize(5);
DataSource dataSource = new HikariDataSource(hikariConfig);
//生成配置
EngineConfig engineConfig = EngineConfig.builder()
//生成文件路径
.fileOutputDir("F:\\Gx")
//打开目录
.openOutputDir(true)
//文件类型
.fileType(EngineFileType.HTML)
//生成模板实现
.produceType(EngineTemplateType.freemarker)
//自定义文件名称
.fileName("数据库设计文档").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.2")
//描述
.description("数据库设计文档生成")
//数据源
.dataSource(dataSource)
//生成配置
.engineConfig(engineConfig)
//生成配置
.produceConfig(processConfig)
.build();
//执行生成
new DocumentationExecute(config).execute();
}

二、swagger3

著名流行接口文档生成,开发效率的保证器

依赖:

1
2
3
4
5
<dependency>  
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>

Swagger3Config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
@Configuration

public class Swagger3Config {
@Bean
public Docket createRestApi() {

return new Docket(DocumentationType.OAS_30)
.apiInfo(apiInfo()).select()
// 扫描所有有注解的api,用这种方式更灵活
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("swagger3接口文档")
.description("接口文档")
.contact(new Contact("张应杨", "#", "1113710198@qq.com"))
.version("0.1.0")
.build();
}
}

WebMvcConfig

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.
addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
.resourceChain(false);
}

/**
* 此处是为了方便浏览器只用敲缀,方便访问
* 本准备使用forward模式,发现forward过去swagger的静态文件访问不了
* swagger静态文件是按照请求路径加载的,这个后续可以想办法在优化
*/
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/swagger")
.setViewName("redirect:/swagger-ui/index.html");
}
}

然后jwt拦截放权限:

1
2
3
4
5
6
7
8
registry.addInterceptor(new JWTInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/swagger-ui/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/swagger-ui.html/**")
.excludePathPatterns("/webjars/**")
.excludePathPatterns("/**/v3/api-docs")
.excludePathPatterns("/swagger/**");

三、linux上刷谷歌

1
2
3
4
5
6
[yum源名称]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
  1. vim /etc/yum.repo.d/google-chrome111.repo 
    
    1
    2
    3

    2. ```
    yum -y install google-chrome-stable --nogpgcheck
  2. google-chrome -version google-chrome-stable --no-sandbox --headless  --dump-dom https://www.baidu.com/ google-chrome-stable --no-sandbox --headless --disable-gpu --dump-dom https://www.douyin.com/?enter=guide
    
    1
    2
    3

    4. ```
    google-chrome --no-sandbox --headless --disable-gpu --screenshot https://lexsaints.blog.csdn.net/article/details/124368382#comments_21268507
  3. google-chrome --no-sandbox --headless --disable-gpu --screenshot https://www.douyin.com/?enter=guide
    

评论