Java Spring属性文件未自动连接,@Value值始终为空

Java Spring属性文件未自动连接,@Value值始终为空,java,spring,rest,web-services,Java,Spring,Rest,Web Services,我有一个SpringWeb应用程序(RESTfulWeb服务) 我的applicationContext.xml中有以下内容可以读取属性文件: <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value=

我有一个SpringWeb应用程序(RESTfulWeb服务) 我的
applicationContext.xml
中有以下内容可以读取属性文件:

 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="ignoreResourceNotFound" value="true" />
    <property name="properties" ref="appProperties" />
</bean>

<bean id="appProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="locations">
        <list>
            <value>classpath:common.properties</value>
            <value>classpath:local.properties</value>
            <value>classpath:${XPLAT_ENV}.properties</value>
        </list>
    </property>
</bean>
但是我的
@Autowired
appProperties
@Value
获取特定属性时总是
NULL
。我看过类似的关于从属性文件注入值的帖子,并尝试了所有可能的建议,但仍然是
NULL
。 还尝试了使用
@PropertySource(“classpath:common.properties”)
但同样的结果

谢谢

编辑:这是applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:metrics="http://www.ryantenney.com/schema/metrics" 
 xmlns:util="http://www.springframework.org/schema/util"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:task="http://www.springframework.org/schema/task"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
 http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task 
http://www.springframework.org/schema/task/spring-task-3.0.xsd
http://www.ryantenney.com/schema/metrics
http://www.ryantenney.com/schema/metrics/metrics.xsd">

<context:component-scan base-package="com.cl.connect" />

<context:annotation-config/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="ignoreResourceNotFound" value="true" />
    <property name="properties" ref="appProperties" />
</bean>

<bean id="appProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="locations">
        <list>
            <value>classpath:common.properties</value>
        </list>
    </property>
</bean>
</beans>

类路径:common.properties

我找到了问题所在,就像上面评论中提到的某个人一样, 我的集成错误,我在我的web.xml中添加了以下内容,并且成功了:

 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>

上下文配置位置
/WEB-INF/applicationContext.xml

我找到了问题所在,就像上面评论中提到的人一样, 我的集成错误,我在我的web.xml中添加了以下内容,并且成功了:

 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>

上下文配置位置
/WEB-INF/applicationContext.xml

编辑添加:My common.properties在src/main/resource中扫描您的整个应用程序context.xmlJAX WS正在分别从Spring实例化您的类。您需要配置集成,以便它从您的Spring上下文检索它们?只需使用SpringRestController,如果使用,则不必手动配置属性spring@Plog添加了applicationContext.xml我需要使用jax ws,因为它是现有项目的一个模块,需要遵循其他项目使用的方法来保持一致性编辑添加:My common.properties在src/main/resourcesCan you中整个applicationContext.xmlJAX WS都在分别从Spring实例化类。您需要配置集成,以便它从您的Spring上下文检索它们?只需使用SpringRestController,如果使用,则不必手动配置属性spring@Plog添加了applicationContext.xml,我需要使用jax-ws,因为它是现有项目的一个模块,需要遵循其他项目所使用的方法来保持一致性