每当我使用 @inject 时,我都会尝试在 tomcat 8 上设置 jsf 2.3 我一直遇到错误我已经在 stackoverflow.com 上搜索和搜索,但我找不到解决方案。我已经按照此处的@BalusC 示例在其上安装了 CDI (Weld)如何在 Tomcat 上安装和使用 CDI?但是我一直有不满意的依赖:没有 bean 与注入点匹配。我想不通我有什么遗漏吗?
配置Bean.java
import static javax.faces.annotation.FacesConfig.Version.JSF_2_3;
import javax.faces.annotation.FacesConfig;
@FacesConfig(
// Activates CDI build-in beans
version = JSF_2_3
)
public class ConfigurationBean {
}
豆类.xml
<?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="all">
</beans>
面孔-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.3"
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/web-facesconfig_2_3.xsd">
</faces-config>
PushBean.java
@Named
@ViewScoped
public class PushBean implements Serializable {
@Inject @Push(channel="counter") //This is where i get the error message unsatisfied dependency: no bean matches the injection point
private PushContext push;
}
对我来说,这段代码看起来不错,但我想知道它是否是 netbeans 错误。我试过不使用spring,只使用带有jsf的tomcat,我仍然收到相同的错误消息。我在堆栈跟踪中找不到任何错误消息。