Java 无法读取spring mvc中的属性文件

Java 无法读取spring mvc中的属性文件,java,spring,spring-mvc,Java,Spring,Spring Mvc,从.properties文件读取属性时,我总是得到空值,我使用的是spring framework 4.0.5版本,使用的是spring STS IDE, 我的代码如下: @Component public class MenuClient { @Value("${menu.list}") private String url; public void showUrl() { System.out.println("url : " + url)

从.properties文件读取属性时,我总是得到空值,我使用的是spring framework 4.0.5版本,使用的是spring STS IDE, 我的代码如下:

@Component
public class MenuClient {

     @Value("${menu.list}")
     private String url;

     public void showUrl() {
         System.out.println("url : " + url); //shows null
     }

}
我的spring配置是这样的


我的项目中是否有任何缺失或错误的配置?

请尝试使用以下配置:

  <context:property-placeholder location="classpath*:config.properties" />
   <context:property-placeholder
    location="classpath*:META-INF/config.properties" />

我发现了这个问题,因为我正在创建这个类的新实例。(初学者错误)在我使用@autowired实例化我的类之后,该值不为null。
感谢@M.Deinum指出根本原因。

可能重复no,我确信我在xml配置中只定义了一次。它不能为空。如果无法解析该值,则启动将失败。确保您自己没有创建该类的新实例。@esthrim查看下面的答案您是否有根应用程序上下文?如果是,你能提供配置吗?