簡體   English   中英

未找到 web 地址的網頁:http://localhost:8080/ 在 Spring 中由 codegen 使用 Z5DB89E7472EAFC67AFC61 生成

[英]No webpage was found for the web address: http://localhost:8080/ in Spring generated by codegen with swagger

我正在使用 swagger 編輯器中的示例寵物商店學習 swagger: https://editor.Z5EAF89E7473/F8672A。

生成 spring 的代碼,我沒有更改任何內容。 但是,每次我在 http://localhost:8080 上運行它時,它都會給出錯誤消息

This localhost page can’t be found
No webpage was found for the web address: http://localhost:8080/
HTTP ERROR 404

但我相信我應該在以下網站上看到類似的內容: https://petstore.swagger.io/請問如何解決這個問題? 非常感謝。

我按照 controller class HomeController 中的 URL。

@Controller
public class HomeController {
    @RequestMapping(value = "/")
    public String index() {
        System.out.println("swagger-ui.html");
        return "redirect:swagger-ui.html";
    }
}

您可能訪問了錯誤的 URL。 試用http://localhost:8080/<base-url>/swagger-ui.html

此外,您可以參考此鏈接進行基本設置。

上下文路徑似乎是 v2。

您應該可以在以下位置訪問演示: http://localhost:8080/v2/<endoint>

嘗試訪問: http://localhost:8080/v2/swagger-ui.html

上下文路徑在位於src/main/resource下的名為application.properties的配置文件中定義。 該文件包含以下內容:

springfox.documentation.swagger.v2.path=/api-docs
server.contextPath=/v2
server.port=8080
spring.jackson.date-format=io.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false

上下文路徑在server.contextPath下定義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM