This application has no explicit mapping for /error, so you are seeing this as a fallback.

项目使用了swagger文档,更新之后突然发现swagger文档页面打不开了 页面展示如下

在网上找了很多途径解决问题,但是不符合我项目的情况,我的解决方式就是分两步:

1,缩小出问题的模块范围

2,对比不出问题的情况的区别

因为有时候日志也是容易让人误导的,比如这次的情况日报报错是这样的:

Controller: org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController
Method    : errorHtml
Params    : 
URI       : /joyfarming/back/error

差点被误导去找BasicErrorController去了。

经过对比之后发现我的项目里新增一个配置类,这个配置类导致的问题,

@Configuration
@EnableWebMvc
@EnableAspectJAutoProxy
@EnableScheduling
@ComponentScan(basePackages = "com.jiangcz.joyfarming.back")
public class ApplicationConfig implements WebMvcConfigurer {
    @Bean
    public Validator validator() {
        ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true)
                .buildValidatorFactory();

        return validatorFactory.getValidator();
    }

    @Bean
    public MethodValidationPostProcessor methodValidationPostProcessor() {
        MethodValidationPostProcessor methodValidationPostProcessor = new MethodValidationPostProcessor();
        methodValidationPostProcessor.setValidator(validator());
        return methodValidationPostProcessor;
    }

}

这个类是用来配置hibernate validator校验方式的 居然导致项目的swagger文档不能访问。

这个错误提示"This application has no explicit mapping for /error, so you are seeing this as a fallback."表示应用程序没有对"/error"路径进行显式的映射,所以你才看到这个错误。解决这个问题的方法有两种。首先,你需要检查配置文件application是否与你的项目文件在同一级目录下。其次,你需要确保控制该页面的controller和控制页面跳转的controller的@RequestMapping后面的地址是否与该页面一致。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [报错:this application has no explicit mapping for /error, so you are seeing this as a fallback.](https://blog.csdn.net/caihongfengzhu/article/details/130165404)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [报错This application has no explicit mapping for /error, so you are seeing this as a fallback.](https://blog.csdn.net/a1782519342/article/details/124749723)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值