Announcement Announcement Module
Collapse
No announcement yet.
how can I use annotation replace "beans xmlns:util="http://www.springframework.org/s" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how can I use annotation replace "beans xmlns:util="http://www.springframework.org/s"

    in my case, I want to inject properties store in properties files using @Value annotation.
    e.g.
    I have a properties file names app.properties, the content is below:
    HTML Code:
    db.username=root
    db.password=123456
    by xml, I can load the properties with the following script.
    HTML Code:
    <beans xmlns:util="http://www.springframework.org/schema/util"  xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> 
    </beans>
    <util:properties id="settings" location="WEB-INF/classes/META-INF/spring/app.properties" />  
    and using the @Value the inject the value.

    HTML Code:
    @Value(#{"settings['db.username']}")
    private String user;   

    the question:
    how can I replace xml with some annotation, then I can use @Value annotation.
    like @PropertySource("classpath:app.properties").
Working...
X