Java報錯:Error creating bean with name 'testController': Injection of resource dependencies failed


報錯如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookRepository' defined in com.sirifeng.testjpa.Mapper.BookRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaMappingContext' while setting bean property 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

 

我吐了,de了兩個小時的bug,最后發現是數據庫的url的一個參數寫錯了,我寫的

spring.datasource.url=jdbc:mysql://localhost:3306/webstore?useUnicode=true&characterEncoding=utf-8&serverTimeZone=UTC


這里的serverTimeZone,寫錯了,應該是serverTimezone,Z寫成大寫了,跟這報錯沒有半毛線關系,對新手來說真的太不友好了啊!!!!

所以寫代碼的時候,特別是這種配置文件的,一定要仔細檢查!!!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM