Springboot设置配置以使用ANT_PATH_MATCHER

问题描述 投票:0回答:1

我将

Swagger-ui 3.0.0
Springboot 2.7.15
一起使用,因为 swagger ui 3.0 使用 ant 路径匹配器,但 Springboot 2.7.15 默认情况下不使用,所以我需要在我的
#spring.mvc.pathmath.matching-strategy = ANT_PATH_MATCHER
 中设置 
application.properties

只是想知道是否有任何方法可以以编程方式设置它。我知道

@EnableWebMvc
可以启用 ant 路径匹配器,但它还引入了其他配置,所以我不喜欢这样做。

我尝试了

extends WebMvcConfigurer

@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
    configurer.setPathMatcher(new AntPathMatcher());
} 

不起作用。

spring-boot swagger-ui
1个回答
0
投票

尝试插入

System.setProperty("spring.mvc.pathmatch.matching-strategy", "ant_path_matcher");
在类中,注释为@SpringBootApplication,在所有其他代码之前的主函数中

© www.soinside.com 2019 - 2024. All rights reserved.