The injection point has the following annotations: - @org.springframework.beans.factory.annotation.
啟動Springboot專案失敗。Error Description:
Field “redisTemplate” in com.example.controller.HttpController required a bean of type ‘org.springframework.redis-core.ReidsTemplate’ that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.springframework.redis-core.ReidsTemplate ’ in your configuration.
但是看了bean的注入是沒有問題的。如下自動注入:
@Autowired
redisTemplae<String LIst> RedisTemplate;
思考:這個報錯不是RedisTemplate的jar包匯入的問題;
是向IOC容器中注入redisTemplate物件時產生的錯誤。因此嘗試將宣告時的泛型去掉:
@Autowired
redisTemplae RedisTemplate;
後再此啟動專案,正常啟動。
總結:在使用@Autowired自動注入,特別是被注入的物件型別是匯入的第三方Class或介面,非自定義的介面時,不要擅自新增泛型。。極容易產生上面的報錯。可以使用型別強轉代替泛型的使用:
List<ProjectVo> list = (List<ProjectVo>) redisTemplate.opsForValue().get("hotProjectList");
相關文章
- Shell Injection & Command Injection
- False SQL Injection and Advanced Blind SQL InjectionFalseSQL
- dependency injection
- 10-Overview-AnnotationsView
- study critical point and saddle point using Hessian Matrix
- Hacking Oracle with Sql InjectionOracleSQL
- SQL Injection via DNSSQLDNS
- [20191217]Oracle C functions annotations.txtOracleFunction
- [20240618]Oracle C functions annotations.txtOracleFunction
- 細說 Android Annotations 註解框架Android框架
- SQL注射/SQL Injection漏洞SQL
- 題解:UVA124 Following Orders
- Appdash原始碼閱讀——Annotations與EventAPP原始碼
- [20241016]Oracle C functions annotations補充.txtOracleFunction
- 什麼是 SAP vocabulary-based annotations
- Denpendcy Injection 8.0新功能——KeyedService
- Android App Injection&&Drozer UseAndroidAPP
- PHP WDDX Serializier Data Injection VulnerabilityPHP
- Drupal - pre Auth SQL Injection VulnerabilitySQL
- Powershell tricks::Code Execution & Process Injection
- The following instances are in the device manifest but not specified in framework compatibility matrix:devFramework
- Android: The following classes could not be instantiated: 解決方法Android
- SampleNet: Differentiable Point Cloud SamplingCloud
- 【淺度渣文】Jackson之jackson-annotations
- 註冊帶有Annotations標記的SchemaOL
- 如何給XML Schema增加Annotations標記BHXML
- [CSS 3] :has()CSS
- [iOS]The following untracked working tree files would be overwritten by mergeiOS
- CF685C Optimal Point
- OpenCV(logPolar()、Point2f())OpenCV
- RuntimeError: An attempt has been made to start a new process before the current process hasError
- Dependency Injection-依賴注入詳解依賴注入
- Zabbix SQL Injection/RCE – CVE-2013-5743SQL
- DVWA靶場實戰(七)——SQL InjectionSQL
- 理解ASP.NET Core - [03] Dependency InjectionASP.NET
- NotImplementedError: Only the following pseudo-classes are implemented: nth-of-type.Error
- Listener refused the connection with the following error:ORA-12514, TNS:listenerError
- Reflect.has() 方法