網上多爲解釋Spring對於此報錯的處理,但由於Spring boot多爲自動配置,所以無法參照舊教程解決此問題。
我遇到的情況是,@Query中,命名寫錯導致,
@Query(value = "select new map(u.id as id, u.name as name) from UserEntity u where u.email like :email")
public List<Object> findByLikeEmailGetIdAndName(String email);
我寫的是from UserEntity
,而實際上,本地僅有User
,將@Query
進行修改
@Query(value = "select new map(u.id as id, u.name as name) from User u where u.email like :email")
public List<Object> findByLikeEmailGetIdAndName(String email);
解決報錯failed to load applicationcontext