IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

三十一、Spring MVC不显示接口文档

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

很多朋友在使用Spring MVC时,会碰到接口文档没有的情况,在此处做一个说明

1、首先保证SwaggerConfig的配置文件中配置正确的Docket对象(即默认扫描的包路径或者基于@ApiOperation注解)

2、其次,区别于SpringBoot的注入,不使用@Configuration注解注入到Spring的IOC容器中,采用<bean>XML注入的方式注入到Spring的容器中,如下:

<bean id="SwaggerConfig" class="com.xiaominfo.swagger.config.SwaggerConfiguration"></bean>

3、需保证注入的SwaggerConfig的bean在Spring的MVC的容器中,因为Spring MVC存在父子容器的关系,如果不将该Bean注入到Spring MVC容器中的话,Swagger就会扫描不到Controller层的接口,自然也就不会显示文档

例如:

<servlet>
    <servlet-name>swaggerDemoMvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
        <!--在第二步中注入的SwaggerConfig的bean需写在spring.xml文件中-->
      <param-value>classpath:config/spring.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

干货推荐

文章永久链接:https://tech.souyunku.com/?p=11121


Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(77) 打赏



未经允许不得转载:搜云库技术团队 » 三十一、Spring MVC不显示接口文档

IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码
IDEA2023.1.3破解,IDEA破解,IDEA 2023.1破解,最新IDEA激活码

评论 抢沙发

大前端WP主题 更专业 更方便

联系我们联系我们

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

微信扫一扫打赏


Fatal error: Uncaught Exception: Cache directory not writable. Comet Cache needs this directory please: `/data/wangzhan/tech.souyunku.com.wp/wp-content/cache/comet-cache/cache/https/tech-souyunku-com/index.q`. Set permissions to `755` or higher; `777` might be needed in some cases. in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php:367 Stack trace: #0 [internal function]: WebSharks\CometCache\Classes\AdvancedCache->outputBufferCallbackHandler() #1 /data/wangzhan/tech.souyunku.com.wp/wp-includes/functions.php(5109): ob_end_flush() #2 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(303): wp_ob_end_flush_all() #3 /data/wangzhan/tech.souyunku.com.wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters() #4 /data/wangzhan/tech.souyunku.com.wp/wp-includes/plugin.php(470): WP_Hook->do_action() #5 /data/wangzhan/tech.souyunku.com.wp/wp-includes/load.php(1097): do_action() #6 [internal function]: shutdown_action_hook() #7 {main} thrown in /data/wangzhan/tech.souyunku.com.wp/wp-content/plugins/comet-cache/src/includes/traits/Ac/ObUtils.php on line 367