我试图使用spring @Resource Annotation将一个util类注入托管bean,但是当我运行该应用程序时,我收到了这个错误。
Caused by: com.sun.faces.spi.InjectionProviderException: javax.naming.NameNotFoundException: Name com.web.bean.Bond is not bound in this Context
at com.sun.faces.vendor.Tomcat6InjectionProvider.inject(Tomcat6InjectionProvider.java:84)
at com.sun.faces.mgbean.BeanBuilder.injectResources(BeanBuilder.java:205)
... 37 more
Caused by: javax.naming.NameNotFoundException: Name com.web.bean.Bond is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
at org.apache.catalina.util.DefaultAnnotationProcessor.lookupFieldResource(DefaultAnnotationProcessor.java:278)
at org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:187)
at com.sun.faces.vendor.Tomcat6InjectionProvider.inject(Tomcat6InjectionProvider.java:82)
我的弹簧配置
<context:annotation-config/>
<context:component-scan base-package="com.web.bean"/>
我使用注释的托管bean
package com.web.bean;
@ManagedBean
@SessionScoped
@Resource
private MailSender mail;
答案 0 :(得分:0)
我已经修复了这个问题而没有使用@Resource Annotation
private MailSender mail = (MailSender) SpringWrapper.getInstance().getBean("mail");