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