异常解决:This application has no explicit mapping for /error, so you are seeing this as a fallback.
程序员文章站
2022-04-06 22:39:36
创建SpringBootDemo测试路径时前端报错,后端无异常Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as a fallback.解决:访问路径不对Application启动类的位置不对:要将Application类放在最外侧,即包含所有子包 ,spring-boot会自动加载启动类所在包下及其子包下的所有组件Applicati....
创建SpringBootDemo测试路径时前端报错,后端无异常
异常信息:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
解决:
- 访问路径不对
- Application启动类的位置不对:要将Application类放在最外侧,即包含所有子包 ,spring-boot会自动加载启动类所在包下及其子包下的所有组件
- Application启动类加上包扫描
- 通过查找资料也可能是springboot的配置文件有误:关于application.yml或application.properties文件中视图解析器的配置问题。在pom文件下的spring-boot-starter-paren版本较高时使用以下配置:spring.mvc.view.prefix/spring.mvc.view.suffix,当pom文件下的spring-boot-starter-paren版本较低时使用以下配置:spring.view.prefix/spring.view.suffix。
-
包扫描
包扫描
包扫描
- 启动类加上包扫描
@SpringBootApplication @ComponentScan(basePackages = {"com.qc.springbootinit"}) public class SpringBootHelloWorldApplication { public static void main(String[] args) { SpringApplication.run(SpringBootHelloWorldApplication.class); } }
拓展:
-
SpringBoot默认包扫描机制是:从启动类所在包开始,扫描当前包及其子包下的所有文件。
-
快速创建springboot项目:使用https://start.spring.io/创建项目时出现连接超时,
可以使用 阿里云创建 springboot项目,在创建时点击:Custom,输入:
https://start.aliyun.com/
本文地址:https://blog.csdn.net/drug1910951117/article/details/108036230
上一篇: 华硕灵耀Pro16怎么样 华硕灵耀Pro16详细评测
下一篇: 谈论Go 什么时候会触发 GC问题
推荐阅读
-
异常解决:This application has no explicit mapping for /error, so you are seeing this as a fallback.
-
springboot整合shiro 报 This application has no explicit mapping for /error, so you are seeing this as a fallback. 错误
-
springboot整合shiro 报 This application has no explicit mapping for /error, so you are seeing this as a fallback. 错误
-
异常解决:This application has no explicit mapping for /error, so you are seeing this as a fallback.