IntelliJ IDEA shows errors when using Spring's @Autowired annotation

前端 未结 26 2377
栀梦
栀梦 2020-12-07 15:40

IntelliJ IDEA is showing errors when I use Spring\'s @Autowired annotation in the class, but the class is functioning without any problem.

Here is this

26条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 15:49

    I might be a little late, but after spending hours and researching on this issue.

    I found out that in the latest version IntelliJ 2020 @AutoWired is optional and constructor based depedency injection is preferable.

    I sloved the problem by simply removing the @AutoWired Annotation from Service and Controller class and using constructor based dependency injection.

    This link might help.

    Happy Coding!

提交回复
热议问题