1. 錯誤頁面:This application has no explicit mapping for /error, so you are seeing this as a fallback.
Application程序應該在最外層的包,包含所有子包,Spring boot會自動加載啟動類所在包下及其子包下的所有組件
2.Not registered via @EnableConfigurationProperties, marked as Spring component, or scanned via @ConfigurationPropertiesScan
使用@ConfigurationProperties 將bean屬性和配置文件綁定時出現此報錯
1.在pom中添加依賴:配置文件處理器,配置文件進行綁定就會有提示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
2.只有這個組件是容器中的組件,才能使用容器提供的功能;
添加@Component 注解加入容器
3.properties配置文件中文亂碼問題
IDEA默認使用的是utf-8,在IDEA設置的File Encodings項里選擇properties Files的編碼為utf-8,並且將transparent native-to-ascii conversion的選項勾上,可以在運行時將properties文件的編碼轉為ascii碼
4.靜態資源引發的錯誤
有可能是因為瀏覽器緩存才導致達不到預期效果,注意排查,清空緩存重新加載
5.發送去請求跳轉頁面時需要注意
請求的方法控制器上不要有@ResController或者該方法上不要注解@ResponseBody
6.使用JDBC連接數據庫出現The server time zone value '�й���ʱ��' is解決方案
url后加入?serverTimezone=UTC即可解決
高版本的 spring boot 搭配 mysql 驅動版本較高時,如 mysql-connector-java:8.0.16,此時 driver-class-name 的值要帶 cj;url 的值要帶時區 serverTimezone
7. The elements [spring.datasource.schema[0].classpath,spring.datasource.schema[1].classpath] were left unbound.
創建表獲取執行語句時報錯,編寫yml的時候多寫了一個空格
錯誤:
schema:
- classpath: schema-all.sql
- classpath: employee.sql
正確:
schema:
- classpath:schema-all.sql
- classpath:employee.sql
8.nested exception is org.springframework.boot.context.properties.source.InvalidConfigurationPropertyValueException: Property spring.datasource.schema with value 'class path resource [employee.sql]' is invalid: The specified resource does not exist.
springboot2.x 執行sql文件時出現的錯,配置文件增加initialization-mode: always
initialization-mode: always
schema:
- classpath:schema-all.sql
- classpath:employee.sql
9. 自定義druidDataSource出現的錯誤
兩種解決方法:
- 導入log4j依賴就可以
- 在filter中去掉log4j