当先锋百科网

首页 1 2 3 4 5 6 7
	在项目交付过程中数据库文档必不可少,但是以往 的编写方式太过费时费力,鉴于数据库编写的文档格式相似,容易使用固定的模版,故而想到了编写文档生成程序;想到了java的开源氛围避免自己费时费力编写程序,故而在github上查找前辈们的成果,用于数据库文档生成;推荐使用screw数据库文档生成器,具体的实施步骤如下:
    一、引入依赖包
      <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.lvhong.screw</groupId>
  <artifactId>screw</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>screw</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <shiro.version>1.4.0</shiro.version>
    <fastjson.version>1.2.28</fastjson.version>
    <cglib.version>3.1</cglib.version>
    <log4j.version>1.3.8.RELEASE</log4j.version>
    <aspectj.version>1.7.4</aspectj.version>
    <springboot.mybatis.version>1.3.2</springboot.mybatis.version>
    <mybatis.version>3.4.6</mybatis.version>
    <druid.version>1.1.9</druid.version>
    <poi.version>3.9</poi.version>
    <activiti.version>6.0.0</activiti.version>
  </properties>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
    <relativePath />
  </parent>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j</artifactId>
      <version>${log4j.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
    </dependency>
    <!-- 集成程序性能监控 -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <!-- 面向切面编程 -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-aop</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjweaver</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.aspectj</groupId>
          <artifactId>aspectjrt</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>${aspectj.version}</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectj.version}</version><!--$NO-MVN-MAN-VER$ -->
    </dependency>
    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>${cglib.version}</version>
    </dependency>

    <!-- 集成redis -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-redis</artifactId>
      <exclusions>
        <exclusion>
          <groupId>io.lettuce</groupId>
          <artifactId>lettuce-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>redis.clients</groupId>
      <artifactId>jedis</artifactId>
    </dependency>

    <!-- mybatis依赖jar -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>${springboot.mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid-spring-boot-starter</artifactId>
      <version>${druid.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>${druid.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>${fastjson.version}</version>
    </dependency>

    <!-- mybatis依赖jar -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>${springboot.mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid-spring-boot-starter</artifactId>
      <version>${druid.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>${druid.version}</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>${fastjson.version}</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>cn.smallbun.screw</groupId>
      <artifactId>screw-core</artifactId>
      <version>1.0.3</version>
    </dependency>
    <!-- HikariCP -->
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
      <version>3.4.5</version>
    </dependency>
    <!--mysql driver-->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.20</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>cn.smallbun.screw</groupId>
        <artifactId>screw-maven-plugin</artifactId>
        <version>1.0.3</version>
        <dependencies>
          <!-- HikariCP -->
          <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>3.4.5</version>
          </dependency>
          <!--mysql driver-->
          <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.20</version>
          </dependency>
        </dependencies>
        <configuration>
          <!--username-->
          <username>root</username>
          <!--password-->
          <password>Pass1234</password>
          <!--driver-->
          <driverClassName>com.mysql.cj.jdbc.Driver</driverClassName>
          <!--jdbc url-->
          <jdbcUrl>jdbc:mysql://localhost:3306/lvhong</jdbcUrl>
          <!--生成文件类型-->
          <fileType>WORD</fileType>
          <!--打开文件输出目录-->
          <openOutputDir>false</openOutputDir>
          <!--生成模板-->
          <produceType>freemarker</produceType>
          <!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
          <!--<docName>测试文档名称</docName>-->
          <!--描述-->
          <description>数据库文档生成</description>
          <!--版本-->
          <version>1.0.0</version>
          <!--标题-->
          <title>数据库文档</title>
        </configuration>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

二、配置数据源

    spring.datasource.url=jdbc:mysql://localhost:3306/lvhong?useUnicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=Pass1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.xa.properties.useInformationSchema=true

三、运行maven的screw插件
配置maven插件,screw:run,生成数据库文档