春天在IntelliJ IDEA社区版不绑定@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.

但是在我的控制器中,我确实有它:

@Autowired
private KitchenService service;

我发现的大多数解决方案都不清楚,唯一明确的解决方案是用@SpringBootApplication的 3 个注释来注释起点类,但没有区别。

如何解决?

首先,Intellij IDEA不是一个免费的IDE。对于大规模开发和框架支持,您需要购买Intellij IDEA Ultimate Edition以获得所有支持。

在免费版中,他们不提供Spring支持。

推荐免费IDE:最好的免费IDESpring Tools Suite。Pivotal团队专门为Spring Framework支持设计了Eclipse IDE,它比任何其他IDE都要好得多。

Pivotal 还建议使用此 IDE。

没有创建KitchenService豆的原因如下:

  1. KitchenService上缺少@Service注释。

  2. 或者您错过了将包添加到存在KitchenService@ComponentScan中。

因此,KitchenServicebean 丢失,Spring 在自动布线时无法找到 bean。

请根据这些原因验证问题。

最新更新