Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 如何使用SpringREST文档可视化index.html页面_Kotlin_Documentation Generation_Spring Restdocs - Fatal编程技术网

Kotlin 如何使用SpringREST文档可视化index.html页面

Kotlin 如何使用SpringREST文档可视化index.html页面,kotlin,documentation-generation,spring-restdocs,Kotlin,Documentation Generation,Spring Restdocs,我基本上开始使用SpringREST文档来生成rest服务的文档。问题是我不知道如何从我的应用程序中可视化文档。我很高兴看到以下结果:。但当我打开这个url时,我看到了一个问题: 白标错误页 此应用程序没有/error的显式映射,因此您将其视为回退 2019年5月22日星期三22:36:46 出现意外错误(类型=未找到,状态=404)。 没有可用的消息 我已经一步一步地使用了nex教程:。我能够遵循所有步骤,现在在我的项目中,我有了以下代码片段: 并且index.html页面也在路径中创建:t

我基本上开始使用SpringREST文档来生成rest服务的文档。问题是我不知道如何从我的应用程序中可视化文档。我很高兴看到以下结果:。但当我打开这个url时,我看到了一个问题: 白标错误页 此应用程序没有/error的显式映射,因此您将其视为回退

2019年5月22日星期三22:36:46 出现意外错误(类型=未找到,状态=404)。 没有可用的消息

我已经一步一步地使用了nex教程:。我能够遵循所有步骤,现在在我的项目中,我有了以下代码片段:

并且index.html页面也在路径中创建:target/generated docs/index.html:

在我的pom.xml中,我添加了下一个插件:

           <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.6</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>
            </plugin>

org.ascidoctor
AscidActor maven插件
1.5.6
生成文档
准备包装
过程ascidoc
索引adoc
html
${project.build.directory}/snippets
最后,我将在下一个类中运行我的应用程序:

@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
@EnableAutoConfiguration
@ComponentScan(
        basePackages = [
            "com.espn.csemobile.espnapp",
            "com.espn.personalization"]
)
open class SportscenterProductApi

fun main(args: Array<String>) {
    val app = SpringApplication(SportscenterProductApi::class.java)
    app.setBannerMode(Mode.LOG)
    app.setLogStartupInfo(true)
    app.run(*args)
}
@配置
@顺序(有序。最高优先级)
@启用自动配置
@组件扫描(
基本包=[
“com.espn.csemobile.espnapp”,
“com.espn.personalization”]
)
开放类SportscenterProductApi
趣味主线(args:Array){
val app=SpringApplication(SportscenterProductApi::class.java)
app.setBannerMode(Mode.LOG)
app.setLogStartupInfo(真)
应用程序运行(*args)
}
有什么想法吗?

因为,您需要对构建进行配置,以便将生成的HTML复制到将打包到应用程序中的位置

在配置
AscidActor maven插件之后,将以下插件配置添加到
pom.xml

<plugin> 
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.7</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <phase>prepare-package</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>