CDI中的自定义范围似乎需要beans.xml

时间:2015-06-11 08:10:33

标签: cdi custom-scope

我在CDI中创建了一个自定义范围。

@NormalScope(passivating = false)
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE,ElementType.METHOD,ElementType.FIELD})
@Inherited
public @interface MyScope { }

只有在我的部署中有beans.xml时才有效。这是必须的吗?

1 个答案:

答案 0 :(得分:1)

我将自定义范围打包为单独的jar并将beans.xml放在里面。现在工作正常。