JavaEE @Specializes 注解在继承中的使用
JavaEE @Specializes annotation usage in inheritence
我的项目中有以下场景。
@Named("a")
class A{ }
@Specializes
class B extends A{ }
@Specializes
class C extends B{ }
class Test{
@Inject
A a1;
}
在测试class中,我想将cclass实例注入到引用变量a1中。我试过了,它总是注入 B。
如何操作?
Some more information:
I also want to mentioned that each of these 3 classes are in defferent projects. I'm tring to access the method from xhtml file not from Test class I'm using EL .
project1---> A
@Named("links")
@ApplicationScoped
class A{
public String getMethod1(){
}
}
project2(dependency to project1)----> B
@Specializes
class B extends A{
@Override
public String getMethod1(){
}
}
project3(dependency to project1,project2)---->C
@Specializes
class C extends B{
@Override
public String getMethod1(){
}
}
project4(dependency to project1,project2,project3)--->
MyPage.xhtm
<ui:include src="#{links.method1()}">
</ui:include>
当我尝试使用 EL 'links' 访问时,总是指向 Class B.
请多多指教。
我的项目结构有多个 Maven 模块的问题。它导致模块的传递依赖。
我的项目中有以下场景。
@Named("a")
class A{ }
@Specializes
class B extends A{ }
@Specializes
class C extends B{ }
class Test{
@Inject
A a1;
}
在测试class中,我想将cclass实例注入到引用变量a1中。我试过了,它总是注入 B。
如何操作?
Some more information:
I also want to mentioned that each of these 3 classes are in defferent projects. I'm tring to access the method from xhtml file not from Test class I'm using EL .
project1---> A
@Named("links")
@ApplicationScoped
class A{
public String getMethod1(){
}
}
project2(dependency to project1)----> B
@Specializes
class B extends A{
@Override
public String getMethod1(){
}
}
project3(dependency to project1,project2)---->C
@Specializes
class C extends B{
@Override
public String getMethod1(){
}
}
project4(dependency to project1,project2,project3)--->
MyPage.xhtm
<ui:include src="#{links.method1()}">
</ui:include>
当我尝试使用 EL 'links' 访问时,总是指向 Class B.
请多多指教。
我的项目结构有多个 Maven 模块的问题。它导致模块的传递依赖。