maven - WELD-001408 对 EJB 项目的依赖不满足
问题描述
我有一个包含三个项目的多模块 Maven 项目。第一个具有共享数据的 ejb 项目test-base
。第二个 ejb 项目test-timer
应部署在 glassfish 4.x 应用程序服务器上以运行定期任务 ( @Scheduel
) 并依赖于test-base
. 最后是第三个带有简单 webapp 的战争项目test-webapp
,它也依赖于test-base
并且也将单独部署到 glassfish 4.x 应用程序服务器。在test-base
项目中是一个 CDI bean。该项目包含 beans.xml。
test-webapp
奇迹般有效。但是,如果我尝试部署,则会test-timer
出现部署异常。
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyCdiBean] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.test.MyTimer.bean]
在网上搜索后(即此处或此处),我认为它与beans.xml
. test-base
包含一个beans.xml
并且 webapp 运行得很好。与test-timer
我是否有beans.xml
没有关系一样。
beans.xml
由 netbeans ide 生成,如下所示。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
我也试图改变bean-discovery-mode="all"
两者test-base
,test-timer
但没有任何改变。
这是我的项目结构。
test-parent
|--test-base
|--src
|--main
|--java
|--org/test/MyCdiBean.java
|--resources
|--META-INF
|--beans.xml
|--test
|--pom.xml
|--test-timer
|--src
|--main
|--java
|--org/test/MyTimer.java
|--resources
|--META-INF
|--beans.xml
|--test
|--pom.xml
|--test-webapp
|--src
|--main
|--java
|--org/test/WebAppBean.java
|--resources
|--META-INF
|--beans.xml
|--webapp
|--WEB-INF
|--web.xml
|--index.xhtml
|--test
|--pom.xml
|--pom.xml
感谢任何关于我做错了什么的提示。
如有必要,我可以附上来源。
编辑评论中要求的附加信息。
现在是新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"
bean-discovery-mode="annotated">
</beans>
仍然不起作用。
我正在使用 WELD 版本WELD-000900 2.0.0 (SP1)
,并使用它进行了测试WELD-000900: 2.2.13 (Final)
MyCdiBean.java 在test-base
@javax.inject.Named
@javax.enterprise.context.RequestScoped
//@javax.enterprise.context.Dependent /* also tried with */
public class MyCdiBean {
public void doSomething() {
System.out.println("Hello World!");
}
}
解决方案
推荐阅读
- audacity - 大胆:静音音频仍然播放一些噪音
- python - 将 json 文档索引到 Elasticsearch 会引发 TransportError
- python - 使用python拆分csv文件中的单列
- python - 列表列表的乘法
- ruby-on-rails - Rails 应用程序意外安装在根文件夹中
- c# - mscorlib.dll 中出现“System.FormatException”类型的未处理异常附加信息:输入字符串的格式不正确
- python - Keras Tokenizer 中词索引的长度
- binding - 使用 Aurelia Property Observer 忽略您自己的更改的最佳方法
- node.js - NPM 全局安装
- json - 使用 Swift JSON 从 TheMovieDB API 获取数据时遇到问题