8--deep use of spring--7...4 using automatic assembly

Source: Internet
Author: User

8.7.4 using automatic assembly

Under the automatic Assembly policy, the action is created by the spring plug-in, and the spring plug-in creates the action instance with spring's automated assembly strategy, which injects the corresponding business logic component into the action instance. The configuration file for this integration strategy is simple, but the controller and business logic components are coupled to the code hierarchy, coupled high.

If automatic assembly is not specified, the system uses automatic assembly by ByName by default. The previous consolidation policy does not specify any automated assembly policies.

The so-called automatic assembly, which allows spring to automatically manage the dependencies between beans and beans, does not require the use of a ref display to specify the dependent bean. The spring container automatically checks the contents of the XML configuration file and injects a dependent bean into the keynote bean. Automatic assembly reduces the amount of configuration files, but reduces the transparency and clarity of dependencies.

By using automatic assembly, you can have the spring plug-in automatically inject the business logic component into the action instance of Struts 2.

By setting the Struts.objectFactory.spring.autoWire constant, you can change the spring plug-in's automatic assembly policy, which can accept several values such as the following:

⊙name: Automatic assembly with ByName.

⊙type: Automatic assembly with Bytype.

The ⊙auto:spring plugin automatically detects the type of automatic assembly that needs to be used.

⊙constructor: Similar to type, the difference is that constructor uses constructors to construct the parameters required for injection, rather than using the set-value injection method.

La La la

8--deep use of spring--7...4 using automatic assembly

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.