且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以将 CDI Bean 注入 Java EE 6 中的静态变量?

更新时间:2022-03-25 07:24:41

一般不做,因为静态变量不能有作用域,即它只是整个类的一个(读取应用程序),因此没有意义因为每个实例都会尝试根据当前范围将其设置为新值.

Not done in general because a static variable cannot have a scope, i.e. it's just one for the whole class (read application) and therefore it doesn't make sense since every instance would try to set it to a new value based on the current scope.