由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - multiple PropertyPlaceHolderConfigurer in spring applicationContext.xml?
相关主题
Spring菜鸟求救JSF, Wicket, and Vaadin
让大家了解工业界Java/J2EE面试题的难度Anyone know SAML 2.0 and OpenSAML ?
两种方式有什么不同spring web service issue
servlet-mapping causing http 404 errormaven,struts求助
a stupid questionSpring的新手问题
Question: EJB Web Services Integration求OpenShift上Spring-quickstart的mysql配置方法
deserializer probelm.Ignore upper. Thx关于 Java bean
高手麻烦帮帮忙。。新手学编程JSF is actually fucking cool
相关话题的讨论汇总
话题: multiple话题: bean话题: ttt话题: spring
进入Java版参与讨论
1 (共1页)
c******n
发帖数: 4965
1
it seems that there can be only one,
although the javadoc says there can be multiple.
there is a bug that makes only the first of multiple
PropertyPlaceholderConfigurer effective.
I need multiple since I want to give a default value for a placeholder in my
bean , provided by my library. if the user uses my library, the bean is
created with default behavior. otherwise if the user does not supply a
config key/val pair in his properties files, the placeholder can not be
resolved and gives an exception
have you been able to use multiple placeHolderConfigurer?
e*****t
发帖数: 1005
2
you can certainly have multiple, but their placeholderprefix and suffix
should be different.

my

【在 c******n 的大作中提到】
: it seems that there can be only one,
: although the javadoc says there can be multiple.
: there is a bug that makes only the first of multiple
: PropertyPlaceholderConfigurer effective.
: I need multiple since I want to give a default value for a placeholder in my
: bean , provided by my library. if the user uses my library, the bean is
: created with default behavior. otherwise if the user does not supply a
: config key/val pair in his properties files, the placeholder can not be
: resolved and gives an exception
: have you been able to use multiple placeHolderConfigurer?

g*****g
发帖数: 34805
3
Write your own implementation to work around this,
should be fairly simple. I remember we went through this before.

my

【在 c******n 的大作中提到】
: it seems that there can be only one,
: although the javadoc says there can be multiple.
: there is a bug that makes only the first of multiple
: PropertyPlaceholderConfigurer effective.
: I need multiple since I want to give a default value for a placeholder in my
: bean , provided by my library. if the user uses my library, the bean is
: created with default behavior. otherwise if the user does not supply a
: config key/val pair in his properties files, the placeholder can not be
: resolved and gives an exception
: have you been able to use multiple placeHolderConfigurer?

c******n
发帖数: 4965
4
do you remember how you circumvented this bug?
thanks

【在 g*****g 的大作中提到】
: Write your own implementation to work around this,
: should be fairly simple. I remember we went through this before.
:
: my

c******n
发帖数: 4965
5
I don't think so
if you check the following simple code
///////////////////////
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TTT {
private String p ;
public String getP() { return p;}
public void setP(String p) { this.p = p;}

public void fun() {
System.out.println("value" + p);
}

public static void main(String args[]) {

ApplicationContext ctx = new ClassPathXmlApplicationContext(
"ttt.xml");

TTT o = (TTT) ctx.getBean("ttt");
o.fun();
}
}
//////////////////////////////////////////////

http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

class="org.springframework.beans.factory.config.
PropertyPlaceholderConfigurer">


p1.properties




class="org.springframework.beans.factory.config.
PropertyPlaceholderConfigurer">


p2.properties








#####################################################
now you have 2 property files, p1.properties comes first, you can see that
if you comment out everything from p1 , it throws an exception;
if p1 and p2 contents are different, the result you get depends on the order
of which PPC section is used first. assuming that these sections could be
from different libraries, and imported, then the order of import becomes
critical, which is not what we normally expect

【在 e*****t 的大作中提到】
: you can certainly have multiple, but their placeholderprefix and suffix
: should be different.
:
: my

r*****s
发帖数: 985
6
https://jira.springsource.org/browse/SPR-6428
depending on what version of spring you are using, if it is 3.1.
Per this bug log:
The alternative is to (a) use the new PropertySourcesPlaceholderConfigurer i
nstead of the traditional PropertyPlaceholderConfigurer; (b) eliminate the f
irst PPC; (c) register a PropertySource with the ApplicationContext's Enviro
nment that contains the properties for the placeholders that need replacemen
t in the PropertySourcesPlaceholderConfigurer, such as ${resourceDirPlaceHol
der} from your original example.

【在 c******n 的大作中提到】
: do you remember how you circumvented this bug?
: thanks

1 (共1页)
进入Java版参与讨论
相关主题
JSF is actually fucking coola stupid question
java source code analyzing toolQuestion: EJB Web Services Integration
help: cannot generate index.html using javadocdeserializer probelm.Ignore upper. Thx
Mini Javadoc Howto -- Re: help: cannot generate index.html using javadoc高手麻烦帮帮忙。。新手学编程
Spring菜鸟求救JSF, Wicket, and Vaadin
让大家了解工业界Java/J2EE面试题的难度Anyone know SAML 2.0 and OpenSAML ?
两种方式有什么不同spring web service issue
servlet-mapping causing http 404 errormaven,struts求助
相关话题的讨论汇总
话题: multiple话题: bean话题: ttt话题: spring