Bonjour,
Voila des heures que je galère à injecter des propriétés venant d'un fichier .properties. J'arrive à les exploiter dans les fichiers XML de configuration, mais je n'arrive pas à les injecter dans une classe, dans un parametre ->

fichier.properties
monProjet-servlet.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
 	<!--  Scan des classes annotées (toutes les classes sont dans le package-->
    <context:component-scan base-package="com.web" />
 
    <!-- Les propriétés du fichier-->
	<context:property-placeholder location="classpath:fichier.properties"/>
</beans>
MaClasse.java
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
@Service("monService")
public class MaClasse{
    private @Value("${fichier.prop}") String maProp;
 
}
J'ai essayer d'autre méthode mais rien n'y fait, aidez moi svp ><

Voila l'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Could not autowire field: private java.lang.String com.web.MaClasse.maProp; nested exception is java.lang.IllegalArgumentException: could not resolve placeholder 'fichier.maProp'