java - MyNotificationService 需要类型为 'org.springframework.mail.javamail.JavaMailSender' 的 bean,但无法找到

标签 java spring-boot environment-variables spring-batch jpa-annotations

我正在从数据库读取/加载环境变量。因此我没有 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/

相关文章:

java - 具有客户端模板的受限页面

maven - 如何将maven多模块spring boot部署到docker容器

spring-boot - SpringJUnit4ClassRunner 测试的配置与 SpringBootTest 冲突

environment-variables - .env 文件是用什么语言编写的?

c++ - WSL 看不到环境变量

java - 在线快速手册 : REST API or Java SDK?

java - 而 "!b.equals(x) || !b.equals(y)"是一个无限循环?

java - Neo4J 和 Spring 返回空关系

windows - 如何设置依赖于另一个的环境变量? ( Windows )

java - 需要帮助 在 javascript 中使用 EL 从模型中获取值