简体   繁体   中英

Adding Spring bean using annotations : placing it & initializing properties values

I've gleaned that adding the context:component-scan will enable adding any jar with bean annotated as @Bean to the spring configuration, but , while getting lost in the Framework reference...

  • How can I add that bean as interceptor on specific channel?
  • How can bean properties be initialized if there's no element in the context.xml to specify them ? (such as String properties)

Thanks to all .... (it's spring framework 3.0.)

You need to use the @Value annotation to inject the value from a property coming from a property file or a -Dproperty

http://static.springsource.org/spring/docs/3.0.4.RELEASE/spring-framework-reference/html/new-in-3.html#new-java-configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM