Good day.

I am writing a small mailing program and at the very beginning I ran into a problem.

When:

@Autowired private JavaMailSender mailSender; public void send() { MimeMessage mimeMessage = mailSender.createMimeMessage(); ---- ะ’ะพั‚ ั‚ัƒั‚ NullPointerExeption; 

Spring-Boot properties:

 #email property spring.mail.host=mail.ukraine.com.ua spring.mail.protocol=smtp spring.mail.port=25 spring.mail.username=eugen@karpkoi.com.ua spring.mail.password=test spring.mail.default-encoding=UTF-8 spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true spring.mail.properties.mail.smtp.ssl.enable=true spring.mail.properties.mail.debug=true spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory 

I tried to create a Bean in the file, but the result is the same.

How to beat this stubborn spring. Thank you in advance.

  • Check that the context is registered and that the class is marked with annotations, for example @Service. - Mikhail Vaysman
  • @MikhailVaysman Thank you, this is all there, but it does not work. Although contextually tell me what you mean, I just added @ ComponentScan to the config path at the starting point of the application. - DethGhost
  • Yes, I meant something like ComponentScan. look also in the log - maybe there will be bean initialization errors. - Mikhail Vaysman

0