应用程序上下文和Web应用程序上下文有什么区别?
我知道WebApplicationContext用于面向Spring MVC架构的应用程序?
我想知道ApplicationContextMVC应用程序有什么用?什么样的豆类定义ApplicationContext?
我有一个使用嵌入式tomcat服务器运行的spring启动应用程序.我部分成功地将springfox-swagger与应用程序集成在一起.如果我执行/ v2/api-docs,我可以在webapp中查看所有api的所有文档.但是,当我尝试从UI访问相同时,它不起作用.以下是详细结果.
输出 - localhost:8080/api/swagger-resources
[ {
"name" : "default",
"location" : "/v2/api-docs",
"swaggerVersion" : "2.0"
} ]
Run Code Online (Sandbox Code Playgroud)
输出 - localhost:8080/api/v2/api-docs
I get valid results. I can confirm that and the output is too large to paste here
Run Code Online (Sandbox Code Playgroud)
但是当我尝试访问swagger-ui时,它不起作用.下面是我调用以访问swagger-ui的不同URL.
http://localhost:8080/swagger-ui.html - UI is loading, but no documentation of API's is present
http://localhost:8080/api/swagger-ui.html - 404 Not Found
http://localhost:8080/springfox - 404 Not Found
http://localhost:8080/api/springfox - 404 Not Found
Run Code Online (Sandbox Code Playgroud)
下面是我的SwaggerConfig.java类
package com.vmware.vrack.lcm;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import …Run Code Online (Sandbox Code Playgroud) 我正在使用spring boot并且我已经添加了swagger到我的依赖项:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的配置:
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
Run Code Online (Sandbox Code Playgroud)
当我去这个网址时:
http:// localhost:8080/v2/api-docs它有效,我得到了json.
swagger ui http:// localhost:8080/swagger-ui.html
现在当我检查chrome中的网络选项卡时,我只是一个空页面,我看到了这个:
Failed to load resource: the server responded with a status of 403 ()
swagger-ui-standalone-preset.js Failed to load resource: the server responded with a status of 403 ()
swagger-ui.css Failed to load resource: the server responded with a status …Run Code Online (Sandbox Code Playgroud)