I have a class FichierCommunRetriever
that use the @Value
annotation of Spring
. But I am struggling to make it work.
So in my application.properties
I have :
application.donneeCommuneDossier=C\:\\test
application.destinationDonneeCommuneDossier=C\:\\dev\\repertoireDonneeCommune\\Cobol
My class FichierCommunRetriever
is using those entries with the following code :
public class FichierCommunRetriever implements Runnable {
@Value("${application.donneeCommuneDossier}")
private String fichierCommunDossierPath;
@Value("${application.destinationDonneeCommuneDossier}")
private String destinationFichierCommunDossierPath;
}
We are loading application.properties
with the following code in the class ApplicationConfig
:
@ImportResource("classpath:/com/folder/folder/folder/folder/folder/applicationContext.xml")
In ApplicationConfig
, I am defining a bean
that use FichierCommunRetriever
in a new thread like that :
Thread threadToExecuteTask = new Thread(new FichierCommunRetriever());
threadToExecuteTask.start();
I suppose that my problem is, since FichierCommunRetriever
is running in a separate thread, the class can't reach the applicationContext
and is not able to give a value.
I'm wondering if the annotation would work or I must change the way I'm getting those values?