Ho i file 2 proprietà a.properties e b.properties ho aggiunto l'ad contesto di applicazione come:Utilizzando annotazione @Value
<context:property-placeholder location="classpath:a.properties" />
<context:property-placeholder location="classpath:b.properties"/>
primo file con le proprietà contiene dettagli della connessione db (questo funziona bene) Secondo: contiene le proprietà utilizzate da alcuni bean specifici. In quel chicco di uso di queste proprietà tramite @Value
annotazione
@Value("#{qw.er}")
private String someA;
@Value("#{as.df}")
private String someB;
Tuttavia ottengo un'eccezione durante l'avvio:
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'
Quello che sto facendo di sbagliato?
E 'possibile utilizzare 2 context:property-placeholder
in un file?
PS: Proprietà qw.er e as.df esistono solo in b.properties di file
Check out [this] (http://stackoverflow.com/questions/317687/how-can-i-inject-a-property-value-into-a-spring-bean-which-was-configured-using). Puoi usare '@Value (" # {myProperties ['github.oauth.clientId']} ")' – GokcenG
in realtà, non ho capito cosa sia 'myProperties' in' @Value ("# {myProperties ['github.oauth .clientId ']} ")' – maks
Mi spiace di aver frainteso la tua domanda. Puoi usare ' ' e quindi '@Value (" # {config ['as.df']} ")' sarà utile. Cercherò anche l'uso di '
GokcenG