There is a strus in the struts2_spring_plugin.xml configuration file. objectFactory. spring. the default value of the autoWire attribute is name, which means you do not want to load it, it will find a bean with the id as name to load it to you (this plug-in automatically injects the Action attributes when generating the action, by default, it is injected by name ), for example:
@ Resource (name = "userManager ")
Public void setUm (UserManager um ){
This. um = um;
}
If you do not add the previous @ Resource (name = "userManager"), it will automatically find you a bean with an id of um for injection.
Another point is that if a bean has been automatically matched by name, no matter what the name configuration of @ component (name = "xxxx") will be found again.
Solve the problem: the attribute name should not be the same as the id of other irrelevant beans. For example, there is a User (SetUser () in UserAction ()) this UserAction should not be called @ Resource (name = "user"). You can change it
@ Resource (name = "useraction"), that is, the id of the Action should not be the same as the attribute name in it.