这个项目中的app-root是什么?

时间:2017-04-19 05:28:46

标签: java tomcat spring-boot swagger swagger-ui

我正在使用this article创建一个Spring引导Restful项目来构建一个restful应用程序,然后this link向它添加swagger2。在second link中,您可以通过访问" http://localhost:8080/your-app-root/swagger-ui.html"来说明您可以在浏览器中测试swagger-ui。我项目中的app-root是什么?它是项目的名称吗?我的项目名称是RestSpringBoot。我试过了#34; http://localhost:8080/RestSpringBoot/swagger-ui.html" 。但我得到以下错误:

Whitelabel错误页面

此应用程序没有/ error的显式映射,因此您将此视为后备。

更新:我使用intellij IDE,我在配置中配置了使用sring boot运行我的项目。当我运行项目并检查URL http://localhost:8080/时,它会给出相同的错误。但是这一个:http://localhost:8080/persons/all将返回一个用户的json。是不是春季启动本身嵌入了tomcat,因此没有必要启动tomcat或在tomcat上部署项目?如果确实如此,为什么通过弹簧启动运行项目访问http://localhost:8080将给出" Whitelabel错误页面"错误。

更新2:当我的春季启动项目正在运行时,我打开此网址:http://localhost:8080/swagger-ui.html但我看不到控制器列表,而是看到此页面: picture

我无法理解的是,当我的项目没有运行时,我再次在http://localhost:8080/swagger-ui.html中看到与上图相同的内容。

2 个答案:

答案 0 :(得分:1)

您指定的项目链接中没有app-root。如您所见,使用http://localhost:8080/greeting访问/ greeting端点。所以,用这个来达到你的招摇ui。 http://localhost:8080/swagger-ui.html
关于spring boot和whitelabel错误页面,你看到这个页面的事实意味着tomcat正在运行,它告诉你它没有你正在尝试的url模式的任何映射(这只是'/')。您应该添加一个控制器并公开您希望在第一个链接GreetingController类中使用的路径(使用RequestMapping)。

答案 1 :(得分:0)

试试:http://localhost:8080/RestSpringBoot/api/swagger-ui.html

我假设你的项目名称是:RestSpringBoot

相关问题