Results 1 to 2 of 2

Thread: File properties injection with annotation

  1. #1
    Join Date
    Dec 2011
    Posts
    3

    Default File properties injection with annotation

    Hi,
    I have propertie in a file:
    file.properties
    Code:
    file.prop=Txt
    I successfully injected this properties into a property of a bean when i create my bean in a XML file.

    But i fail to inject with annotation, i do that :
    spring-servlet.xml
    Code:
    [...]
    <context:component-scan base-package="com.web" />
    <context:property-placeholder location="classpath:file.properties"/>
    </beans>
    This is not a path error, the loading of file works

    myClass.java
    Code:
    @Service("myClass")
    public class MyClass{
        private @Value("${file.prop}") String myProp;
     [...]
    }
    And the error
    Code:
    Could not autowire field: private java.lang.String com.web.MyClass.myProp; nested exception is java.lang.IllegalArgumentException: could not resolve placeholder 'file.prop'
    I hope you have a solution ^^

  2. #2
    Join Date
    Dec 2011
    Posts
    3

    Default

    WTF ?
    I have relaunch my project and it works Oo

Tags for this Thread

Posting Permissions

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