異常情況下初始化過程中遇到 - 取消刷新嘗試:org.springframework.beans.factory.UnsatisfiedDependencyException:錯誤創建名爲「rabbitMqController」豆:不滿意依賴通過現場「recordsReprositry表達「;嵌套異常是org.springframework.beans.factory.NoSuchBeanDefinitionException:沒有可用的bean類型'com.rabbitmq.config.RecordsReprositry'可用:預計至少有1個bean有資格作爲autowire候選者。依賴註解:{@ org.springframework.beans.factory.annotation.Autowired(必需=真)}我在使用彈簧污物reprositry面臨的問題
1
A
回答
0
它看起來像你註釋interface..while你應該把@Repository它的實現類。
package com.rabbitmq.config;
import java.util.UUID;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public **interface** RecordsReprositry extends CrudRepository<Records, Long>{
public Records findById(UUID id);
}
0
從春天嘗試JPA ...(DOC:http://docs.spring.io/spring-data/jpa/docs/current/reference/html/)
例子:
@Repository
public interface MyRepository extends JpaRepository<EntityName,Long> {
// here you can write your query; example:
EntityName findByAttribute(Type value);
// or
@Query("SELECT * FROM EntityName t WHERE t.ID=?1")
EntityName findByID(Long id);
}
然後你就可以使用這個服務庫(必須使用自動裝配Autowired)
示例:
@Service
public class MyService{
@Autowired
private MyRepository repo;
// here you can call in a method your query
public EntityName example() {
EntityName e = repo.findByID((long)1);
return e;
}
}
重要提示:您只能在服務中使用存儲庫,並且您必須在控制器中使用該服務器
相關問題
- 1. 使用彈簧時的問題TransactionSynchronizationManager
- 2. 我在使用彈簧配置啓動服務器時遇到問題。我正在使用Zk彈簧
- 3. 我面臨的問題在陣列
- 4. 面臨的問題,從購物車中刪除物品笨
- 5. 使用Ant和麪臨的問題
- 6. 導致使用彈簧在購物車中實現購物車
- 7. 彈簧配置問題
- 8. 嵌套彈簧TxProxyTemplate問題
- 9. 彈簧mvc映射問題
- 10. Hazelcast彈簧集成問題
- 11. 彈簧注射問題
- 12. 採用帶彈簧的引導問題
- 13. 彈簧安全2.0.7和彈簧2.5的登錄表單問題
- 14. Javascript彈簧物理:將方向矢量應用於彈簧
- 15. 使用中,我面臨的COM組件有問題的線程
- 16. 彈簧應用程序SonarQube問題S3749
- 17. 使用彈簧
- 18. 彈簧批中的臨時表
- 19. 面臨的strtotime問題()
- 20. 時所面臨的問題
- 21. JBehave面臨的問題
- 22. 數組面臨的問題
- 23. 問題我面臨dateFormat.parse(字符串)?
- 24. 我面臨浮點問題嗎?
- 25. 我面臨rails驗證問題
- 26. 子彈物理問題
- 27. 我正面臨的問題;我似乎編碼的Javascript裏面
- 28. 404錯誤的彈簧安全問題?
- 29. eclipseLink事務問題的彈簧啓動
- 30. 彈簧集成中的DataHub問題
請顯示您定義存儲庫的方式。 stacktrace不足以幫助您解決問題 – Andrew
package com.rabbitmq.config; import java.util.UUID; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository 公共接口RecordsReprositry延伸CrudRepository <記錄,龍> { \t公共記錄findById(UUID ID); \t } –
您可以編輯您的問題以提供其他信息。粘貼控制器和存儲庫中的代碼有 – Andrew