Spring 问题解决
本文最后更新于:2024年9月8日 晚上
Spring 问题解决
未加上@ResponseBody注释导致无法启动
报错:org.thymeleaf.exceptions.TemplateInputException: Error resolving template [clock/export], template might not exist or might not be accessible by any of the configured Template Resolvers
解决方法:在controller前加上@ResponseBody
注释。
配置文件不生效
原因
- Maven可能存在资源过滤的问题。
- java版本不对,无法正常编译配置文件。
解决方法:
- 将
pom
配置完善。
1 |
|
- 指定java版本。
1 |
|
缺少log4j依赖
报错:java.lang.ClassNotFoundException: org.apache.log4j.Priority
解决方法:导入 log4j 依赖即可。
1 |
|
Spring Boot 启动失败
报错:org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
解决方法
- 检查入口 Application 文件是否加了
@SpringBootApplication
注解,或者@SpringBootConfiguration
,@EnableAutoConfiguration
两个注解。 - 检查
pom.xml
是否正确添加 web 依赖。
1 |
|
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!