我正在从数据库读取/加载环境变量。因此我没有 application.properties。
我收到以下错误消息
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.MyNotificationService required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.
- Bean method 'mailSender' not loaded because AnyNestedCondition 0 matched 2 did not; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.JndiNameProperty @ConditionalOnProperty (spring.mail.jndi-name) did not find property 'jndi-name'; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.HostProperty @ConditionalOnProperty (spring.mail.host) did not find property 'host'
Action:
Consider revisiting the conditions above or defining a bean of type 'org.springframework.mail.javamail.JavaMailSender' in your configuration.
最佳答案
Spring 似乎无法创建 MyNotificationService 的实例,因为它的构造函数需要 JavaMailSender 类型的 bean。
在堆栈的更下方,您可以看到它无法找到几个属性。如果您想从数据库加载属性,请使用下面的教程
https://pure-essence.net/2011/02/10/spring-loading-properties-from-database-with-a-twist/
关于java - MyNotificationService 需要类型为 'org.springframework.mail.javamail.JavaMailSender' 的 bean,但无法找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56260186/