使用screw一键生成数据库文档

screw是一款简洁好用的数据库表结构文档生成器(maven插件)。
github:https://github.com/pingfangushi/screw
下面使用Spring Boot对screw进行集成。

一. screw的配置

  1. 配置pom文件

<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.0modelVersion>
	<parent>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-parentartifactId>
		<version>2.2.9.RELEASEversion>
		<relativePath /> 
	parent>
	<groupId>com.beegroupId>
	<artifactId>screw-demoartifactId>
	<version>0.0.1-SNAPSHOTversion>
	<name>screw-demoname>
	<description>Screw Demo for Spring Bootdescription>

	<properties>
		<java.version>1.8java.version>
	properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.bootgroupId>
			<artifactId>spring-boot-starter-webartifactId>
		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>cn.smallbun.screwgroupId>
			<artifactId>screw-coreartifactId>
			<version>1.0.4version>
		dependency>

	dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.bootgroupId>
				<artifactId>spring-boot-maven-pluginartifactId>
			plugin>
			<plugin>
				<groupId>cn.smallbun.screwgroupId>
				<artifactId>screw-maven-pluginartifactId>
				<version>1.0.4version>
				<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>123456password>
					
					<driverClassName>com.mysql.cj.jdbc.DriverdriverClassName>
					
					<jdbcUrl>jdbc:mysql://localhost:3306/db_mybatisjdbcUrl>
					
					<fileType>HTMLfileType>
					
					<openOutputDir>falseopenOutputDir>
					
					<produceType>freemarkerproduceType>
					
					<description>数据库文档生成description>
					
					<version>1.0.0version>
					
					<title>数据库文档title>
				configuration>
				<executions>
					<execution>
						<phase>compilephase>
						<goals>
							<goal>rungoal>
						goals>
					execution>
				executions>
			plugin>
		plugins>
	build>
project>
  1. 配置数据源
    src/main/resources/application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/db_mybatis?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.usename=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.xa.properties.useInformationSchema=true

二. 通过Maven插件运行screw

  1. IDEA中运行
    使用screw一键生成数据库文档_第1张图片
  2. Eclipse中运行
  • 处理POM配置文件中的错误(也可以不管这个错误,直接运行
    使用screw一键生成数据库文档_第2张图片
    使用screw一键生成数据库文档_第3张图片
    使用screw一键生成数据库文档_第4张图片
  • 运行
    使用screw一键生成数据库文档_第5张图片
    使用screw一键生成数据库文档_第6张图片
    在Goals中输入:screw:run

三. 生成数据库各表的设计文档

使用screw一键生成数据库文档_第7张图片

你可能感兴趣的:(java,数据库,screw)