gpt4 book ai didi

JSF 2.3 CDI 不能在 tomcat 上运行

转载 作者:行者123 更新时间:2023-12-05 06:34:46 24 4
gpt4 key购买 nike

每当我使用@inject 时,我都试图在 tomcat 8 上设置 jsf 2.3 我一直有错误我在 stackoverflow.com 上用谷歌搜索和搜索,但我找不到解决方案。我已经按照@BalusC 示例在此处安装了 CDI(焊接)How to install and use CDI on Tomcat?但我一直有不满意的依赖:没有bean匹配注入(inject)点。我想不通我是否遗漏了什么?

配置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 {
}

beans.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>

faces-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 只使用 tomcat 和 jsf 我仍然收到相同的错误消息。我在堆栈跟踪中找不到任何错误消息。 Screen shot of the warning message in netbeans

最佳答案

Spring 不是一个完整的 CDI 容器,它只“知道”@Named@Inject 注释,因此(很可能)不识别 @Push 注释作为限定符,找不到 bean 并抛出你得到的错误(发布一个显式错误和堆栈跟踪是你应该在问题中总是做的事!)

另请参阅:

关于JSF 2.3 CDI 不能在 tomcat 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50096079/

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