[英]How can I inject a property value into a Spring Bean which was configured using annotations?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
I have a bunch of Spring beans which are picked up from the classpath via annotations, eg我有一堆 Spring bean,它们是通过注释从类路径中提取的,例如
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
// Implementation omitted
}
In the Spring XML file, there's a PropertyPlaceholderConfigurer defined:在 Spring XML 文件中,定义了一个PropertyPlaceholderConfigurer :
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WEB-INF/app.properties" />
</bean>
I want to inject one of the properties from app.properites into the bean shown above.我想将 app.properites 中的一个属性注入到上面显示的 bean 中。 I can't simply do something like我不能简单地做类似的事情
<bean class="com.example.PersonDaoImpl">
<property name="maxResults" value="${results.max}"/>
</bean>
Because PersonDaoImpl does not feature in the Spring XML file (it is picked up from the classpath via annotations).因为 PersonDaoImpl 在 Spring XML 文件中没有特征(它是通过注释从类路径中提取的)。 I've got as far as the following:我有以下几点:
@Repository("personDao")
public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao {
@Resource(name = "propertyConfigurer")
protected void setProperties(PropertyPlaceholderConfigurer ppc) {
// Now how do I access results.max?
}
}
But it's not clear to me how I access the property I'm interested in from ppc
?但我不清楚如何从ppc
访问我感兴趣的财产?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.