Announcement Announcement Module
Collapse
No announcement yet.
File properties injection with annotation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    WTF ?
    I have relaunch my project and it works Oo

    Comment

    Working...
    X