MyNotificationService required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found

784 views Asked by At

I'm reading/loading environment variables from Database. Hence I do not have application.properties.

I'm getting the following error message

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.
1

There are 1 answers

3
tsingh On

It seems spring could not create instance of MyNotificationService as its constructor requires bean of type JavaMailSender.

Further down in stack you could see that its not able to find couple of properties. if you want to load properties from db could, use tutorial below

https://pure-essence.net/2011/02/10/spring-loading-properties-from-database-with-a-twist/