问题描述
当 bean-discovery-mode 从“all”更改为“annotated”时,CDI bean 不起作用。
javax.el.PropertyNotFoundException: //C:/Users/XYZ/Documents/_java/JavaWeb/src/main/webapp/test.xhtml @22,75 value="#{testBean.prop1}":目标不可达,标识符 'testBean' 解析为 null com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100) 在 com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95) 在 javax.faces.component.UIInput.getConvertedValue(UIInput.java:1045) 在 javax.faces.component.UIInput.validate(UIInput.java:975) 在 javax.faces.component.UIInput.executeValidate(UIInput.java:1248) 截断。请参阅日志文件以了解由以下原因引起的完整堆栈跟踪: javax.el.PropertyNotFoundException:目标不可达,标识符 'testBean' 解析为 null com.sun.el.parser.AstValue.getTarget(AstValue.java:173) 在 com.sun.el.parser.AstValue.getType(AstValue.java:85) 在 com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201) 在 org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93) 在 org.jboss.weld.el.WeldValueExpression.getType(WeldValueExpression.java:93) 截断。查看日志文件以获取完整的堆栈跟踪
beanx.xml
.5
TestBean.java 已经用 RequestScoped 进行了注释。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="annotated">
</beans>
test.xhtml
package bean;
@javax.inject.Named()
@javax.enterprise.context.RequestScoped
public class TestBean implements java.io.Serializable {
static final long serialVersionUID = 1L;
static final org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();
private String uid;
private String prop1;
@javax.annotation.PostConstruct
public void PostConstruct() {
this.uid = String.valueOf(System.currentTimeMillis());
logger.debug("uid: {}",this.uid);
logger.debug("prop1: {}",this.prop1);
}
@javax.annotation.PreDestroy
public void PreDestroy() {
}
public void doAction() {
logger.debug("uid: {}",this.prop1);
}
public String getProp1() {
return prop1;
}
public void setProp1(String prop1) {
this.prop1 = prop1;
}
}
想知道“带注释的”bean 发现模式是如何工作的,我想念什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)