I do not know if this is a Spring Boot issue, but here we go.
If one autowires in final JavaMailSender javaMailSender and have the related props in the prod and dev properties files then javaMailSender will have a red line under itself in Intellij saying "Could not autowire. No beans of 'JavaMailSender' type found. ".
For example like this:
@Autowired public EmailServiceImpl(final JavaMailSender javaMailSender, @Value("${server.address}") String projectHostIp, @Value("${server.port}") String projectPort, @Value("${project.name}") String projectName, @Value("${spring.mail.sent-from}") String mailSentFrom) { this.javaMailSender = javaMailSender; this.projectHostIp = projectHostIp; this.projectPort = projectPort; this.projectName = projectName; this.mailSentFrom = mailSentFrom; }
In Dev & Prod:
JavaMail
spring.mail.host=smtp.something.com spring.mail.port=123 spring.mail.username=something@something.com spring.mail.password=somePassword spring.mail.sent-from=no-reply@something.com spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true
But if the "# JavaMail" code in "Dev & Prod" files are moved to "application.properties" then the red error / warning disappears.
Comment From: wilkinsona
Thanks for the report, but that doesn't sound like a Spring Boot problem to me. I would guess that IntelliJ is assuming that neither the dev or prod profile is active and, therefore, that no JavaMailSender
will be auto-configured. Perhaps it's possible to configure it so that it activates the dev or prod profiles when determining what beans are available?