Struts single case mode, and spring proxy mode and non-single case mode @scope ("prototype")

Source: Internet
Author: User

The bean in the 1:spring container defaults to a single case pattern, and the change to a non-single mode requires adding @scope ("prototype") to the class

2: After adding @scope ("prototype"), the reference to the class can not be injected with @autowired

3:struts2 default is a non-single case mode.

4: In non-single case mode, adding synchronized to the method has no effect, synchronized only works on the same object.

So don't add synchronized restrictions to the anction in struts, because adding and not adding is the same effect.

5: In the case of single mode Class A, there is a b,c class called B in a, which is probably a single example. You can use Hashcode to see.

@Scope ("prototype")
@Service ("Gjsaleorderserviceimpl") Public
class Gjsaleorderserviceimpl implements Igjsaleorderservice {

Other classes refer to the above class

@Resource (name= "Gjsaleorderserviceimpl")

Private Gjsaleorderserviceimpl Saleorderservice; Don't use @autowired.


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.