Netbeans:奇怪的焊接行为

时间:2011-05-31 21:18:39

标签: java cdi jboss-weld netbeans-7

在官方documentation之后,我实施了一个非常简单的Java SE Weld快速入门类。

@Singleton
public class TesteCDI {

    public void printHello(@Observes ContainerInitialized event, 
         @Parameters List<String> parameters) {
       System.out.println("Hello Weld!" + parameters);
   }
} 

我的运行配置会触发org.jboss.weld.environment.se.StartMain

这是有趣的部分。 如果我不创建Jar文件(单击“清理并生成”),则不会打印我的消息。

54 [main] INFO org.jboss.weld.Version - WELD-000900 1.1.0 (Final)
110 [main] INFO org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
388 [main] WARN org.jboss.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled
388 [main] WARN org.jboss.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled

如果我确实创建了Jar文件,那么从命令行和Netbeans都可以正常运行。所以我假设Netbeans正在运行jar中的应用程序。

问题是...... 不是

如果我更新我的Test类并从Netbeans运行,它会选择更改。如果我从命令行运行jar,它只打印旧消息。

如果我清理我的项目,Netbeans启动配置将停止打印消息。

任何人都可以解释Netbeans运行我的应用程序的确切方式吗?这种奇怪的行为是否有意义或是否应被视为错误?

1 个答案:

答案 0 :(得分:1)

我认为如果忘记了META-INF / beans.xml,焊接不会选择带注释的组件,你是否检查了类路径中是否有META-INF / beans.xml?