Skip to content

Latest commit

 

History

History

springboot-restdocs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Springboot 整合Spring Rest docs

1.Restdocs

pom

添加依赖

<dependency>
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-mockmvc</artifactId>
    <scope>test</scope>
</dependency>

添加插件

<build>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <id>generate-docs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <sourceDocumentName>index.adoc</sourceDocumentName>
                            <backend>html</backend>
                            <attributes>
                                <snippets>${project.build.directory}/snippets</snippets>
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.restdocs</groupId>
                        <artifactId>spring-restdocs-asciidoctor</artifactId>
                        <version>1.2.1.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

添加adoc模板

src/main/asciidoc/index.adoc

asciidoc文档语法请参考:http://asciidoctor.org/docs/asciidoc-syntax-quick-reference

编写测试文件

src/test/java/com/zyd/AppTest.java

其他文档生成工具

2.Swagger2(这个也需要掌握、使用)

生命不息,折腾不止!

更多信息,请关注:

  1. 我的博客
  2. 我的工具
  3. 我的微博
  4. 我的头条号
  5. 我的mooc

有任何问题可以

如果喜欢,请多多分享、多多Star