SpringMvc+Swagger整合springSwaggerConfig 沒法注入錯誤處理

我用的是註解的方式 
自定義類的DEMOspring

 

@Configuration
@EnableSwagger
@EnableWebMvc
public class SwaggerConfig
{api

    public SpringSwaggerConfig springSwaggerConfig;spring-mvc

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

    @Bean
    public SwaggerSpringMvcPlugin customImplementation(){
        return  new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
                .apiInfo(new ApiInfo("api", "desc", null, null, null, null))
                .useDefaultResponseMessages(false)
                .includePatterns("/app.*");
    }
}app

 

這裏要注意 
1.@EnableWebMvc這個要有,我百度上好多的文章都沒有這個註解 
2.個人spring-mvc.xml裏面的配置是沒有 
<bean class="com.xxx.xxx.CustomJavaPluginConfig"/>和 
<bean class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" /> 
的配置項 
3.有的文章說去掉@Configuration而後xml裏面配置上 
<bean class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" />,這樣是能夠跑通,這時會生成一個默認的Config類,你本身自定義的CustomJavaPluginConfig這個類就沒有用了this

相關文章
相關標籤/搜索