![](/img/trans.png)
[英]IntelliJ IDEA Community Edition and Spring slow reload with Spring DevTools
[英]Spring in IntelliJ IDEA Community Edition does not bind @Autowired
我也看到了有關付費版本的問題,但找不到解決方案。 IDEA CE 抱怨缺少應該定義的 bean。
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'domain.service.KitchenService' in your configuration.
但在我的 controller 中,我確實有它:
@Autowired
private KitchenService service;
我發現的大多數解決方案都不清楚,唯一明確的一個是用@SpringBootApplication 的 3 個注釋來注釋起點@SpringBootApplication
,但沒有區別。
如何解決?
首先,Intellij IDEA 不是免費的 IDE。 對於大規模開發和框架支持,您需要購買 Intellij IDEA Ultimate Edition 以獲得所有支持。
在免費版中,他們不提供 Spring 支持。
免費推薦 IDE:最好的免費 IDE 是Spring 工具套件。 Pivotal team has specially designed the Eclipse IDE for Spring Framework support and it's far better than any other IDE.
而且Pivotal也推薦使用這個IDE。
KitchenService
bean 沒有創建的原因如下:
KitchenService
上缺少@Service
注釋。
或者您錯過了在存在 KitchenService 的@ComponentScan
中添加KitchenService
。
因此, KitchenService
bean 丟失,並且 Spring 在自動裝配時無法找到 bean。
請根據這些原因驗證問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.