java - Spring: @Value vs. @Autowired -


i'm having issues injection in application i'm working on (using spring version 3.1.2). start with, i'm seeing lot of code this:

@value("#{searchrequestbean}") private searchrequest searchrequest;  @value("#{searchresponsebean}") private searchresponse searchresponse;  @autowired private savedsearchservice service; 

each of these 3 appears have effect of autowiring specified bean/service class. don't understand is, what's difference between @value , @autowired in these cases? every example find online seems use @value inject values properties file. in case, searchresponse , searchrequest abstract classes.

i'm hoping better understanding of me solve issues i'm having session bean.

@value can used injecting default values. example inject default of string value of property file. in example, @value used set default value of class spring managed bean.

@autowired can't used first example: it's not property file aware. @autowired only di of bean. more specific @value, can use @value same thing.

here tutorial @value: http://www.mkyong.com/spring3/spring-value-default-value/


Popular posts from this blog