Announcement Announcement Module
Collapse
No announcement yet.
Reading properties from a file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading properties from a file

    hi all

    i try to read properties from a file. my configuration looks like that
    PHP Code:
    <context:property-placeholder  location="classpath*:whitelists.properties" ignore-resource-not-found="false" /> 
    then i try to set the value with the @value annotation:

    PHP Code:
    @Value("${email.exclude}")
    private 
    String emailWhitelist
    but i get the following error:
    PHP Code:
    Caused byjava.lang.IllegalArgumentExceptionCould not resolve placeholder 'email.exclude'
        
    at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:173)
        
    at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:125
    the property is defined in whitelists.properties:
    PHP Code:
    email.exclude=test@test.ch 
    so what am i doing wrong?

    regards
    angela

  • #2
    I tested your code, it works just fine.

    Comment


    • #3
      i had to change the location because the file was locatet in src/main/webapp/WEB-INF:

      <contextroperty-placeholder location="WEB-INF/whitelists.properties" />

      Comment

      Working...
      X