Springmvc different implementation classes that call the same interface with @qualifier annotations

Source: Internet
Author: User

#在controller中定义接口并使用spring注解方式 @autowired for assembly work

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8A/CB/wKiom1g7_-WAkaP5AABpJ7nwIsk246.jpg-wh_500x0-wm_3 -wmp_4-s_1759237548.jpg "style=" Float:none; "title=" 1.jpg "alt=" Wkiom1g7_-wakap5aabpj7nwisk246.jpg-wh_50 "/>

#对不同的service进行get和set, and use @qualifier to label the service name in the set method.

Note that the service name marked here must be consistent with the Bean's ID in spring's corresponding XML!

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M00/8A/CB/wKiom1g7_-WwCHudAAChwxKoyho499.jpg-wh_500x0-wm_3 -wmp_4-s_3800649732.jpg "style=" Float:none; "title=" 2.jpg "alt=" Wkiom1g7_-wwchudaachwxkoyho499.jpg-wh_50 "/>

#在对应controller中

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/8A/C7/wKioL1g7_-ayTEqiAADMJiirHPM652.jpg-wh_500x0-wm_3 -wmp_4-s_3783027372.jpg "style=" Float:none; "title=" 3.jpg "alt=" Wkiol1g7_-ayteqiaadmjiirhpm652.jpg-wh_50 "/>

#实现类2

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8A/C7/wKioL1g7_-fAekwqAABhM63wESw577.jpg-wh_500x0-wm_3 -wmp_4-s_3774037322.jpg "style=" Float:none; "title=" 4.jpg "alt=" Wkiol1g7_-faekwqaabhm63wesw577.jpg-wh_50 "/>

#实现类1

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8A/CB/wKiom1g7_-eSQhMuAABtTV__46I125.jpg-wh_500x0-wm_3 -wmp_4-s_2508386408.jpg "style=" Float:none; "title=" 5.jpg "alt=" Wkiom1g7_-esqhmuaabttv__46i125.jpg-wh_50 "/>


#spring对应xml中配置对应javabean, the name of the bean corresponding ID must be consistent with the service name in the controller!

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/8A/C7/wKioL1g7_-jS4uXrAAHfbAqQmko491.jpg-wh_500x0-wm_3 -wmp_4-s_1998717551.jpg "style=" Float:none; "title=" 6.jpg "alt=" Wkiol1g7_-js4uxraahfbaqqmko491.jpg-wh_50 "/>


This article is from the "You can choose Extraordinary" blog, please be sure to keep this source http://ylcodes01.blog.51cto.com/5607366/1877471

Springmvc different implementation classes that call the same interface with @qualifier annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.