spring - How to use <component-scan> for controllers without using @Autowired? -


in context configuration uses <component-scan> auto-detect , create @controller beans, i'd avoid having use @autowired annotations on controller properties (for various reasons need/prefer explicitly inject beans controllers need). controller has property setters marked @required. how can declare beans injected controllers in scenario?

in other words: use of <component-scan> require use of @autowired, , if not, how accomplish injection of @required properties?

by way, hoping spring component-scan without autowiring? answer question, answer assumes "clients" (the controllers in scenario) not annotated kind of @component themselves.

i don't think can leave in component-scanning and, @ same time, wiring manually (in xml) dependencies of beans being component-scanned.

if use component scanning, tell spring create bean instances. if define bean in xml, tell spring create bean instances. if in both ways, 2 bean instances. want spring creating beans when sees @controller annotation go xml , see dependencies has. what's point in having component-scanning in first place, if still end doing bean in xml?!

if want selective component-scanning (which different matter compared autowiring only) have quite few options. this section in reference documentation describes them well.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -