Results 1 to 3 of 3

Thread: Reading properties from a file

  1. #1
    Join Date
    Apr 2010
    Posts
    8

    Lightbulb 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. #2
    Join Date
    Oct 2012
    Location
    Shenzhen, China
    Posts
    13

    Default

    I tested your code, it works just fine.

  3. #3
    Join Date
    Apr 2010
    Posts
    8

    Default

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

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •