Spring mvc 大摇大摆不给SpringMVC项目提供UI

Spring mvc 大摇大摆不给SpringMVC项目提供UI,spring-mvc,swagger,swagger-ui,Spring Mvc,Swagger,Swagger Ui,我对Swagger并不熟悉,并试图在springmvc中实现它。我正在使用最新的dependencyswagger springmvcfrom。所以基于链接。我在mvc config.xml中添加了以下配置 <!-- Serve static content - required for Swagger --> <mvc:default-servlet-handler/> <!-- to enable the default documentati

我对
Swagger
并不熟悉,并试图在
springmvc
中实现它。我正在使用最新的dependency
swagger springmvc
from。所以基于链接。我在
mvc config.xml
中添加了以下配置

<!-- Serve static content - required for Swagger -->
    <mvc:default-servlet-handler/>

    <!-- to enable the default documentation controller-->
    <context:component-scan base-package="com.mangofactory.swagger.controllers"/>

    <!-- to pick up the bundled spring configuration-->
    <context:component-scan base-package="com.mangofactory.swagger.configuration"/>

    <!-- Direct static mappings -->
    <mvc:resources mapping="*.html" location="/, classpath:/swagger-ui"/>
当我启动网站时:
http://localhost:8080/dp-rest/api文档
我看不到UI格式,它只提供JSON格式

{"apiVersion":"1.0","swaggerVersion":"1.2","apis":[{"path":"/default/student-service","description":"Manage Student Service","position":0},{"path":"/default/student-service","description":"Manage Student Service","position":0}],"authorizations":[],"info":{"title":"Student API's","description":"API for Student ","termsOfServiceUrl":"terms.html","contact":"test@yahoo.com","license":"Commercial Proprietary","licenseUrl":"http://www.adbc.com"}}
纽约

为什么用户界面格式在我们启动网站时不出现?
然后我只看到原始JSON响应,没有任何ui,这里缺少什么?我需要更改/添加/修改哪些代码?

根据文章,您将看到一个部分,告诉您在哪里可以找到文档。我不确定你是否在使用spring boot,但是

在做了这些更改之后,我可以用“mvn spring boot:run”打开并在浏览器中查看应用程序

在任何情况下,swagger springmvc现在都被调用并支持最新的swagger规范(2.0)。还有一些方法可以帮助您开始。我建议改用springfox的(截至本文撰写时为2.3.1)

git clone https://github.com/wordnik/swagger-ui
cp -r swagger-ui/dist ~/dev/x-auth-security/src/main/webapps/docs
{"apiVersion":"1.0","swaggerVersion":"1.2","apis":[{"path":"/default/student-service","description":"Manage Student Service","position":0},{"path":"/default/student-service","description":"Manage Student Service","position":0}],"authorizations":[],"info":{"title":"Student API's","description":"API for Student ","termsOfServiceUrl":"terms.html","contact":"test@yahoo.com","license":"Commercial Proprietary","licenseUrl":"http://www.adbc.com"}}
@Configuration
@EnableSwagger
public class SwaggerConfig {
    private SpringSwaggerConfig springSwaggerConfig;

    @Autowired
    public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
        this.springSwaggerConfig = springSwaggerConfig;
    }

    @Bean
    // Don't forget the @Bean annotation
    public SwaggerSpringMvcPlugin customImplementation() {
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(
                apiInfo()).includePatterns(".*");
    }

    private ApiInfo apiInfo() {
        return new ApiInfo("Student API", "API for Student",
                "term.html", "test@tahoo.com",
                "Commercial Proprietary", "http://www.test.com");
    }
}