Monday, 15 July 2013

java - When is @Autowired invoked for a bean? -



java - When is @Autowired invoked for a bean? -

for bean :

@autowired private mybean mybean;

is bean autowired before :

@requestmapping("view") public string showview { //mybean null here }

reason i'm asking mybean set null. other beans have

@rendermapping("normal") public string rendernormal{ //mybean not null here }

mybean seems autowired correctly.

is @requestmapping("view") causing mybean not wired or beingness invoked before spring autowires mybean ? if how can configure spring wire mybean before entering method showview ?

update : missing <context:annotation-config /> in spring context file, question provides detail on utilize : difference between <context:annotation-config> vs <context:component-scan>

the lone @requestmapping annotation doesn't create class spring bean.

usually, @requestmapping goes hand-by-hand @controller annotation (which extends @component annotation) it's considered spring bean , (according javadoc)

represent component receives httpservletrequest , httpservletresponse instances

java spring

No comments:

Post a Comment