亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Spring Boot + Swagger 導出Pdf,Html

發布時間:2020-07-18 21:10:25 來源:網絡 閱讀:2452 作者:路遙o_o 欄目:編程語言

1. Maven 配置

    <dependency>
        <groupId>io.github.swagger2markup</groupId>
        <artifactId>swagger2markup</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>nl.jworks.markdown_to_asciidoc</groupId>
        <artifactId>markdown_to_asciidoc</artifactId>
        <version>1.0</version>
    </dependency>

    <dependency>
        <groupId>org.pegdown</groupId>
        <artifactId>pegdown</artifactId>
        <version>1.6.0</version>
        <scope>test</scope>
    </dependency>

2. plugin 配置

  <!--此插件生成ASCIIDOC-->
        <plugin>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup-maven-plugin</artifactId>
            <version>1.2.0</version>
            <configuration>
                <!--此處端口一定要是當前項目啟動所用的端口-->
                <swaggerInput>http://127.0.0.1:9092</swaggerInput>
                <outputDir>src/docs/asciidoc/generated</outputDir>
                <config>
                    <!-- 除了ASCIIDOC之外,還有MARKDOWN和CONFLUENCE_MARKUP可選 -->
                    <swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
                </config>
            </configuration>
        </plugin>

        <!--此插件生成HTML和PDF-->
        <plugin>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctor-maven-plugin</artifactId>
            <version>1.5.3</version>
            <!-- Include Asciidoctor PDF for pdf generation -->
            <dependencies>
                <dependency>
                    <groupId>org.asciidoctor</groupId>
                    <artifactId>asciidoctorj-pdf</artifactId>
                    <version>1.5.0-alpha.10.1</version>
                </dependency>
                <dependency>
                    <groupId>org.jruby</groupId>
                    <artifactId>jruby-complete</artifactId>
                    <version>1.7.21</version>
                </dependency>
            </dependencies>
            <!-- Configure generic document generation settings -->
            <configuration>
                <sourceDirectory>src/docs/asciidoc/generated</sourceDirectory>
                <sourceHighlighter>coderay</sourceHighlighter>
                <attributes>
                    <toc>left</toc>
                </attributes>
            </configuration>
            <!-- Since each execution can only handle one backend, run
                 separate executions for each desired output type -->
            <executions>
                <execution>
                    <id>output-html</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>process-asciidoc</goal>
                    </goals>
                    <configuration>
                        <backend>html5</backend>
                        <outputDirectory>src/docs/asciidoc/html</outputDirectory>
                    </configuration>
                </execution>

                <execution>
                    <id>output-pdf</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>process-asciidoc</goal>
                    </goals>
                    <configuration>
                        <backend>pdf</backend>
                        <outputDirectory>src/docs/asciidoc/pdf</outputDirectory>
                    </configuration>
                </execution>

            </executions>
        </plugin>

3.新建GneratorSwaggerPdfAndHtml --- UT

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class GneratorSwaggerPdfAndHtml {
public void generateAsciiDocs() throws Exception {
// 輸出Ascii格式
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.ASCIIDOC)
.build();
Swagger2MarkupConverter.from(new URL("http://localhost:9092/v2/api-docs"))
.withConfig(config)
.build()
.toFolder(Paths.get("src/docs/asciidoc/generated"));
}
}

4. Swagger2AutoConfiguration 配置

本地 Swagger2AutoConfiguration類,繼承WebMvcConfigurationSupport,并重寫addResourceHandlers方法
@Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
       registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

5.編譯命令生成PDF,Html

先執行命令mvn asciidoctor:process-asciidoc

Run 此UT,會生成Adoc文件。

然后執行 命令 mvn generate-resources 生成PDF和HTML

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

乐亭县| 惠安县| 丰台区| 莱西市| 武汉市| 清远市| 安义县| 连江县| 安丘市| 新化县| 临汾市| 从化市| 昭苏县| 平湖市| 荃湾区| 乐昌市| 沙雅县| 华安县| 余姚市| 南溪县| 吴桥县| 德安县| 宁阳县| 冀州市| 土默特左旗| 常山县| 永新县| 滕州市| 丽水市| 东平县| 循化| 永胜县| 济南市| 德令哈市| 亳州市| 扎兰屯市| 定结县| 宜章县| 藁城市| 墨竹工卡县| 凤凰县|