jsf – WELD-001408:具有限定符@Default的Customer类型的不满意
发布时间:2020-12-14 00:52:01 所属栏目:百科 来源:网络整理
导读:我是Java EE新手。我想测试JSF,因此制作了一个简单的程序,但无法部署它。我收到以下错误消息: cannot Deploy onlineshop-wardeploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408
我是Java EE新手。我想测试JSF,因此制作了一个简单的程序,但无法部署它。我收到以下错误消息:
cannot Deploy onlineshop-war deploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Customer with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private de.java2enterprise.onlineshop.RegisterController.customer at de.java2enterprise.onlineshop.RegisterController.customer(RegisterController.java:0) . Please see server.log for more details. 我的代码如下: package de.java2enterprise.onlineshop.model; public class Customer { private String email; private String password; } registerController.java: package de.java2enterprise.onlineshop; import java.io.Serializable; import javax.enterprise.context.RequestScoped; import javax.inject.Named; import javax.inject.Inject; import de.java2enterprise.onlineshop.model.*; @Named @RequestScoped public class RegisterController { private static final long serialVersionUID = 1L; @Inject private Customer customer; public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public String persist() { return "/index.xhtml"; } } 为了编译它,我必须包含cdi-api.jar作为外部库。谁在这里谁可以帮助我?谢谢大家。
您的Customer类必须由CDI作为bean发现。为此你有两个选择:
>把bean defining annotation放在上面。因为@Model是一个刻板印象,所以它就是这样做的原因。像@Named这样的限定符不是定义注释的bean,因为它不起作用 请记住@Named只有一个用法:将bean暴露给UI。其他用法是针对不良实践或与遗留框架的兼容性。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |