0

spring-restdocs 1.1.0.BUILD-SNAPSHOTのテストサンプルに従いました。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ディレクトリにgenerated-snippets ディレクトリが構成されていることを確認します。

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