J'ai la configuration suivante dans un ressort applicationContext.xmlPuis-je utiliser util: propriétés et contexte de Spring: propriété-espace réservé ensemble?
<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<context:property-placeholder location="file:///absolute/path/to/foo.properties"/>
<context:property-placeholder location="file:///absolute/path/to/bar.properties"/>
<util:properties id="baz" location="file:///absolute/path/to/bar.properties"/>
Je peux mettre des points d'arrêt de débogage où les fichiers de propriétés sont chargés et voir les valeurs des fichiers de propriétés sont en effet chargés.
Mais dans mon haricot, @Value("#{baz.myProp}")
est résolu alors @Value("${myProp}")
coups dans PropertyPlaceholderHelper
, comme PropertySourcesPropertyResolver
ne peut pas trouver myProp
:
DEBUG [...] - Searching for key 'myProp' in [environmentProperties]
DEBUG [...] - Searching for key 'myProp' in [systemProperties]
DEBUG [...] - Searching for key 'myProp' in [systemEnvironment]
DEBUG [...] - Could not find key 'myProp' in any property source. Returning [null]
DEBUG [...] - Searching for key 'myProp' in [localProperties]
DEBUG [...] - Could not find key 'myProp' in any property source. Returning [null]
Pourquoi est-ce et comment puis-je le faire fonctionner (en utilisant l'espace réservé de la propriété $
résolution, au lieu de la syntaxe #
SpEL)?
Les propriétés chargées via context:property-placeholder
sont-elles supprimées/écrasées par util:properties
(accessible uniquement via la référence baz
)?
Ne pas (comme vous aurez probablement manquer d'importantes exceptions). Utilisez un seul «espace-propriété» avec une liste d'emplacements séparés par des virgules. –