0

我遵循了spring-restdocs 1.1.0.BUILD-SNAPSHOT的 testng 示例。我能够通过 gradle 生成 adoc 文件。但是当我使用 maven 时,它不会生成 doc 文件。

Mmy pom.xml有以下详细信息:

<dependency> 
    <groupId>org.springframework.restdocs</groupId>
    <artifactId>spring-restdocs-mockmvc</artifactId>
    <version>1.1.0.BUILD-SNAPSHOT</version>
    <scope>test</scope>
</dependency>
<plugin> 
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <includes>
            <include>**/*TestNgApplicationTests.java</include>
        </includes>
    </configuration>
</plugin>
<plugin> 
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoctor-maven-plugin</artifactId>
    <version>1.5.2.1</version>
    <executions>
        <execution>
            <id>generate-docs</id>
            <phase>prepare-package</phase> 
            <goals>
                <goal>process-asciidoc</goal>
            </goals>
            <configuration>
                <backend>html</backend>
                <doctype>book</doctype>
                <attributes>
                    <snippets>${snippetsDirectory}</snippets> 
                </attributes>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/classes/static/docs</outputDirectory>
                <resources>
                    <resource>
                        <directory>${project.build.directory}/generated-docs</directory>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
4

1 回答 1

2

尝试从您的终端使用此命令运行:

$> mvn package
  • 生成的文件应该在/target.
    • 生成的片段应该在/target/generated-snippets.
    • 生成的.html应该在/target/generated-docs.

确保您已将生成的片段目录配置为测试类的/target目录:

@Rule
public RestDocumentation restDocumentation = 
    new RestDocumentation("target/generated-snippets");
于 2016-03-16T00:21:27.693 回答