No matching bean of type [org.springframework.mail.javamail.JavaMailSenderImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
谁能指出我做错了什么?
bean的xml配置是:
diobject@R_301_49@">
EmailServiceImpl类:
@Service
public class EmailServiceImpl implements EmailService {
@Autowired
private JavaMailSenderImpl emailSender;
//more code..
}
最佳答案
对于一个编码如下的电子邮件服务类,我正在努力解决这个问题:
原文链接:https://www.f2er.com/spring/432609.html@Service("emailService")
public class EmailService {
@Autowired private JavaMailSenderImpl mailSender;
...
public void send(...) {
// send logic
}
}
我在阅读有关相关主题的同时阅读了一个解决方案.关键点在于JavaMailSender接口在applicationContext.xml中定义为Spring JavaMailSenderImpl类.
@Service("emailService")
public class EmailService {
@Autowired private JavaMailSender mailSender; // Observe the change in the type
...
瞧!春天很开心.我想听听原始错误的正确解释.