我正在从数据库中读取/加载环境变量。因此,我没有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.
答案 0 :(得分:0)
似乎spring无法创建MyNotificationService的实例,因为其构造函数需要JavaMailSender类型的Bean。
进一步往下看,您会发现它无法找到几个属性。如果您想从数据库加载属性,请使用下面的教程
https://pure-essence.net/2011/02/10/spring-loading-properties-from-database-with-a-twist/