您好我正在尝试部署使用Spring Mail发送电子邮件的服务。该服务正在我的本地IDE中工作,我正在尝试将其部署在PCF云中。我做了一个gradle构建并在类路径上有manifest.yml文件。当我推它时,应用程序无法启动以下异常。这是我缺少的东西还是PCF行为或电子邮件服务不会在云端?
我正在使用spring boot,并且我拥有所有必需的属性,这些属性有助于在我的application.properties文件中为邮件创建bean。它完全在我当地工作。
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field:
private org.springframework.mail.javamail.JavaMailSender com.send.SendController.mailSender; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [org.springframework.mail.javamail.JavaMailSender] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
更新
@Autowired
private JavaMailSender mailSender;
private void sendEmail(String[] emails) {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("************");
message.setTo(emails);
message.setSubject("Hello");
message.setText("Test mail from Spring!!!");
mailSender.send(message);
}
application.properties
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.password=***********
spring.mail.username=*********
spring.mail.properties.mail.transport.protocol=smtp
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.debug=true
spring.mail.properties.mail.smtp.timeout=1000
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.ssl.enable = true
我还有一个疑问,在我的本地,它连接到互联网以验证电子邮件和发送电子邮件。它如何连接到云中的互联网?我很新,很感激帮助!