springboot 2.6.* 版本核swagger 3.0版本的兼容问题,启动失败解决方案

//正常启动的时候,直接就启动异常了,找对应的匹配配置没有找到。
//就是启动的时候上下文加载的时候没有找到对应swagger 的配置资源
org.springframework.context.ApplicationContextException:Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
Caused by: java.lang.NullPointerException: null
springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns

//解决方案,再yml文件中增加配置
spring:
  mvc:
    pathmatch:
    #设置匹配策略
      matching-strategy: ant_path_matcher

//再springboot2.5.* 和 2.6.* 与swagger 2.0匹配是不需要配置方式的
//代码,路径匹配,下面是简单的使用位置,策略提供的代码位置再什么 地方,大家可以debug一下,跟踪一下
public static class Pathmatch {
		/**
		 * Choice of strategy for matching request paths against registered mappings.
		 */
		private MatchingStrategy matchingStrategy = MatchingStrategy.PATH_PATTERN_PARSER;
		public void setMatchingStrategy(MatchingStrategy matchingStrategy) {
			this.matchingStrategy = matchingStrategy;
		}
}
//是两种路径匹配策略模式,两种不同的风格
public enum MatchingStrategy {

		/**
		 * Use the {@code AntPathMatcher} implementation.
		 */
		ANT_PATH_MATCHER,

		/**
		 * Use the {@code PathPatternParser} implementation.
		 */
		PATH_PATTERN_PARSER

	}


springboot 2.6.* 版本核swagger 3.0版本的兼容问题,启动失败解决方案_第1张图片

你可能感兴趣的:(算法+java,spring,boot,java,spring)