首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与应用程序一起发布spring-restdocs html文档

与应用程序一起发布spring-restdocs html文档
EN

Stack Overflow用户
提问于 2018-03-29 14:03:52
回答 3查看 2K关注 0票数 3

我有带有spring的spring-boot应用程序,我希望在该应用程序中为生成的文档创建端点。使用生成的html文档(由asciidoctor)公开端点的最佳方法是什么?

我可以将index.html包含到jar文件中,但不知道如何创建端点来消耗该html,并公开在测试阶段之后和构建jar阶段之前生成的outside.This html。

从官方文档中:您可以将您创建的HTML文档发布到一个静态网站,或者将其打包,并从应用程序本身提供服务。

例如,我在‘build/asctiidoctor/html5 5’文件夹中有index.html,并希望创建将返回该index.html的控制器。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-03-29 16:20:36

根据文档,您可以将您的构建系统(Maven,Gradle)配置为将HTML打包到Spring中作为静态内容,这样Spring‘自动’就可以为其提供服务。

在第4.6级和Spring 2.0的情况下,:

代码语言:javascript
复制
bootJar {
    dependsOn asciidoctor 
    from ("${asciidoctor.outputDir}/html5") { 
        into 'static/docs'
    }
}

然后可以通过'localhost:<your-port>/<your-context-path/docs/index.html在本地进行验证。

票数 12
EN

Stack Overflow用户

发布于 2020-11-03 10:40:03

若要使用url http://localhost:8081/docs/api-guide.html在本地使用spring引导访问api指南,请添加以下插件:

代码语言:javascript
复制
           <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>${asciidoctor-maven-plugin.version}</version>
            <executions>
                <execution>
                    <id>generate-docs</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>process-asciidoc</goal>
                    </goals>
                    <configuration>
                        <backend>html</backend>
                        <doctype>book</doctype>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.restdocs</groupId>
                    <artifactId>spring-restdocs-asciidoctor</artifactId>
                    <version>${spring-restdocs.version}</version>
                </dependency>
            </dependencies>
        </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>${maven-resources-plugin.version}</version>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.outputDirectory}/static/docs
                        </outputDirectory>
                        <resources>
                            <resource>
                                <directory>
                                    ${project.build.directory}/generated-docs
                                </directory>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>`
票数 1
EN

Stack Overflow用户

发布于 2019-10-22 12:28:37

在从AsciiDoc中生成html之后,只需将html文件复制到target/generated-docs (参见https://spring.io/guides/gs/testing-restdocs/)。然后,Spring将在端点<.>/docs/index.html中获取并保存文档。

你可以用maven-resources-plugin做这份工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49558157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档