首页 > 导入org.springframework.beans.annotation.Autowired 报错

导入org.springframework.beans.annotation.Autowired 报错

package hello;

import org.springframework.beans.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MessagePrinter {

    final private MessageService service;

    @Autowired
    public MessagePrinter(MessageService service) {
        this.service = service;
    }

    public void printMessage() {
        System.out.println(this.service.getMessage());
    }
}

依赖的包已经在maven dependencies中了,为什么还是报错呢?

有时候就是IDE反应慢的问题吧,去试一下IDEA?


已解决,谢谢大家!

【热门文章】
【热门文章】