Я пишу Java Spring приложение, которое отправляет электронные письма. Я получаю данные (адреса электронной почты) из базы данных SQL. Я импортировал нужное хранилище базы данных, но Spring не может внедрить этот зависимый. Моя почта Mail выглядит следующим образом:
@Service
public class MailService {
private final Logger log = LoggerFactory.getLogger(MailService.class);
private final static String USER = "user";
private final String baseUrl;
private final ApplicationProperties applicationProperties;
private final JavaMailSenderImpl javaMailSender;
private final MessageSource messageSource;
private final SpringTemplateEngine templateEngine;
private UserRepository userRepository;
@Autowired
public void setUserRepository(UserRepository userRepository) {
this.userRepository = userRepository;
}
public MailService(ApplicationProperties applicationProperties, JavaMailSenderImpl javaMailSender,
MessageSource messageSource, SpringTemplateEngine templateEngine) {
this.applicationProperties = applicationProperties;
this.javaMailSender = javaMailSender;
this.messageSource = messageSource;
this.templateEngine = templateEngine;
baseUrl = applicationProperties.getBaseUrl();
javaMailSender.setPort(applicationProperties.getPort());
javaMailSender.setHost(applicationProperties.getHostName());
}
Я получаю ошибку:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method setUserRepository in com.test.mail.service.MailService required a bean of type 'com.test.repository.UserRepository' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.test.repository.UserRepository' in your configuration.
Кто-нибудь знает, что это может быть? Спасибо.