gpt4 book ai didi

java - 修复命名空间问题后出现 BeanCreationException

转载 作者:行者123 更新时间:2023-12-02 02:56:57 26 4
gpt4 key购买 nike

这是 org.xml.sax.SAXParseException;cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found 的后续问题该问题中的问题已解决,但我现在看到 BeanCreationException 在我进行更改之前正在运行的内容。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'employeeService': Injection of autowired dependencies failed; nested exception is 
org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.mail.SimpleMailMessage com.xxx.service.EmployeeService.templateMessage; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.mail.SimpleMailMessage] 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)}

我的 REST Controller 是这样注释的

@RestController
public class EmployeeController

还有我的服务

@Service("employeeService")
public class EmployeeService

最佳答案

在您的 applicationContext xml 文件中添加此/类似内容。

<bean id="simpleMailMessage"
class="org.springframework.mail.SimpleMailMessage">

<property name="from" value="from@no-spam.com" />
<property name="to" value="to@no-spam.com" />
<property name="subject" value="Testing Subject" />
<property name="text">
<value>
<![CDATA[
Dear %s,
Mail Content : %s
]]>
</value>
</property>
</bean>

关于java - 修复命名空间问题后出现 BeanCreationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42942032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com