2013-07-17 18 views
5

私はa.propertiesb.properties 2つのプロパティファイルを持っているを使用して、私は、アプリケーションのコンテキストに追加しました:プロパティを持つ最初のファイルは、(DB接続の詳細が含まれてい@value注釈

<context:property-placeholder location="classpath:a.properties" /> 
<context:property-placeholder location="classpath:b.properties"/> 

これは正常に動作します) 2番目の - 特定のBeanによって使用されるプロパティが含まれています。私は@Value注釈

@Value("#{qw.er}") 
private String someA;  
@Value("#{as.df}") 
private String someB; 

を経由して、これらのプロパティを使用してそのBeanで は、しかし、私は、起動時に例外を取得:

org.springframework.expression.spel.SpelEvaluationException: 
EL1008E:(pos 0): Field or property 'qw' cannot be found on object of type 
'org.springframework.beans.factory.config.BeanExpressionContext' 

私が間違ってやっていますか?

1つのファイルに2 context:property-placeholderを使用できますか?

PS:プロパティqw.erとas.dfファイルb.propertiesにのみ存在

+0

[this](http://stackoverflow.com/questions/317687/how-can-i-inject-a-property-value-into-a-spring-bean-which-was-configured-using )。あなたは '@Value("#{myProperties ['github.oauth.clientId']} ")' – GokcenG

+0

を実際に使って、 '@Value('#{myProperties ['github.oauth .clientId ']} ")' – maks

+0

申し訳ありません、私はあなたの質問を誤解しました。あなたは ''を使い、 '@Value("#{config ['as.df']} ")'が役に立ちます。私は ' GokcenG

答えて

9

あなたの特性を定義した後、あなたが

お知らせの$記号を使用する必要がありますhere

を説明されています。