相当于在java中使用@Autowired接口

时间:2022-07-21 08:43:15

I have an interface ITestClass..and there are methds which implements ItestClass..While using in spring if i use @Autowired ITestClass itestClass,spring will find the implemented class and call the respective method from that class during runTime..how is that possible without spring and without using reflections..

我有一个接口ITestClass..and有一些方法实现ItestClass..While在春天使用如果我使用@Autowired ITestClass itestClass,spring将找到实现的类并在runTime期间从该类调用相应的方法。如果可能的话没有弹簧,没有使用反射..

2 个解决方案

#1


3  

You use @Inject That is supposed to be the standard equivalent for JEE.

你使用@Inject应该是JEE的标准等价物。

Furthermore, you can use it with Spring as well. :)

此外,您也可以将它与Spring一起使用。 :)

#2


0  

You can use CDI and @Inject annotation.

您可以使用CDI和@Inject批注。

The concept and the process to find the class that implements an interface. In other words is the Dependency Injection.

查找实现接口的类的概念和过程。换句话说就是依赖注入。

Generally, CDI is an specification applied in JEE environment.

通常,CDI是在JEE环境中应用的规范。

#1


3  

You use @Inject That is supposed to be the standard equivalent for JEE.

你使用@Inject应该是JEE的标准等价物。

Furthermore, you can use it with Spring as well. :)

此外,您也可以将它与Spring一起使用。 :)

#2


0  

You can use CDI and @Inject annotation.

您可以使用CDI和@Inject批注。

The concept and the process to find the class that implements an interface. In other words is the Dependency Injection.

查找实现接口的类的概念和过程。换句话说就是依赖注入。

Generally, CDI is an specification applied in JEE environment.

通常,CDI是在JEE环境中应用的规范。