【发布时间】:2014-09-02 12:13:15
【问题描述】:
我正在搭建JavaEE7中学习CDI的基本环境。我有以下代码用于启动Weld。只是启动和关闭。
package com.anshbansal;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
public class Main {
public static void main(String[] args) {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
weld.shutdown();
}
}
我在我的控制台上得到关注。
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Softs/Programming/Java/Java%20JARs/JBoss%20Weld-2.0.3/jar/weld-se.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Softs/Programming/Java/Java%20JARs/JBoss%20Weld-2.0.3/jar/weld-servlet.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[main] INFO org.jboss.weld.Version - WELD-000900 2.0.3 (Final)
[main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
有问题的行是WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.。这仅仅意味着依赖注入将不起作用。但我不确定是什么问题。我在CLASSPATH 中添加了weld-se.jar。我什至还没有达到初始化对象的地步,那么为什么会出现这个问题?
Weld 的官方文档也给出了我在阅读 this answer 后得到的相同代码。 “Antonio Goncalves”的“Beginning Java EE 7”一书中使用了相同的代码。我已经验证了来自this github location 的导入。因此,如果我使用了正确的类路径并且没有创建任何对象,那么为什么会出现这个问题?
【问题讨论】:
-
你不会通过使用 Java SE Weld 包来学习 Java EE。
-
@SotiriosDelimanolis 我...我只是不知道我是如何错过它是 se 而不是 ee。我复制并粘贴了最初运行它的代码。
标签: java jakarta-ee cdi weld