I'm trying to autowire JavaMailSender
@Autowired
private JavaMailSender javaMailSender;
I have add these to pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
and these to application properties:
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=xxx
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
and the project run correctly (i successed send a mail). but intellij show error on javaMailSender variable. and when i hover my mouse to the error it show
"Could not autowire. No beans of 'JavaMailSender' type found."
How can I fix this error?