Interface1接口有两个实现类Interface1Impl1和Interface1Impl2
Interface1接口:
/***Createdbyliuzhon2018-05-2*接口1*/publicinterfaceInterface1{voidfun1();}以下是接口的两个实现类,请注意@service注解的使用方式,这里给每个实现类标注了不同的名称,方便在@Resource注入时区别注入
Interface1接口实现类
importcoexamplservicInterface1;importorspringframeworstereotypService;
/***Createdbyliuzhon2018-05-2*/@Service('s1')publicclassInterface1Impl1implementsInterface1{@Overridepublicvoidfun1(){Systeout.println('接口1实现类...');}
publicvoidfun2(){Systeout.println('接口1实现类1fu.');}}Interface1接口实现类
importcoexamplservicInterface1;importorspringframeworstereotypService;
/***Createdbyliuzhon2018-05-2*/@Service('s2')publicclassInterface1Impl2implementsInterface1{@Overridepublicvoidfun1(){Systeout.println('接口1实现类...');}
publicvoidfun2(){Systeout.println('接口1实现类2fu.');}}通过@Autowired和@Qualifier配合注入
@Autowired@Qualifier('interface1Impl1')Interface1interface1;//正常启动使用@Resource注入,根据默认类名区分
@Resource(name='interface1Impl1')Interface1interface1;//正常启动使用@Resource注入,根据@Service指定的名称区分
@Resource(name='s1')Interface1interface1;//正常启动使用@Resource注入,根据@Service指定的名称区分,可以避免多个实现类在不同包下,但是类名相同的情况。
文章为作者独立观点,不代表股票配资公司观点
丅劃弦2023-04-07
那不跟庄家干起来了吗?这么大的量,少花六个亿?多花六个亿吧?涨几十个点就得多少股票和柚子进来,股价几天就抬上去了,你以为钱进来跟股价没关系,你试试十个亿进来什么状态?