springmvc+swagger

发布于 2021-12-01 00:59:35 字数 91 浏览 721 评论 7

如何将swagger结合到springmvc项目中?

能有个HelloWorld的Demo就更好了

有没有这方面的详细文档?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

墨洒年华 2021-12-05 05:09:30

可以看看这篇文章http://blog.csdn.net/zjx2016/article/details/73923995

绝影如岚 2021-12-05 04:30:40

springMVC扫描注入就可以了,不需要特别的注入bean,不能出现重复注入,不然会报错!

掩饰不了的爱 2021-12-05 02:44:57

你好,你的注入失败的问题解决了吗?我也出现这个问题了

可是我不能没有你 2021-12-04 19:02:24

怎么配置的?

怎么提示注入失败

springSwaggerConfig

xml

@Configuration
@EnableSwagger
public class SwaggerConfig {
    @Autowired
    private SpringSwaggerConfig springSwaggerConfig;

    /**
     * Required to autowire SpringSwaggerConfig
     */

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

    /**
     * Every SwaggerSpringMvcPlugin bean is picked up by the swagger-mvc
     * framework - allowing for multiple swagger groups i.e. same code base
     * multiple swagger resource listings.
     */
    @Bean
    public SwaggerSpringMvcPlugin customImplementation() {
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo()).includePatterns(".*?");
    }

    private ApiInfo apiInfo() {
        ApiInfo apiInfo = new ApiInfo(
                "My Apps API Title",
                "My Apps API Description",
                "My Apps API terms of service",
                "My Apps API Contact Email",
                "My Apps API Licence Type",
                "My Apps API License URL");
        return apiInfo;
    }
}

注入不成功

醉酒的小男人 2021-12-02 21:25:28

好像有个项目,可以看看:

https://github.com/martypitt/swagger-springmvc

瀞厅☆埖开 2021-12-02 08:43:24

移除 @Configuration 试试

https://github.com/springfox/springfox/issues/462

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文