我有一個類FichierCommunRetriever
,它使用Spring
的@Value
註釋。但我正在努力使其工作。@Value註釋不返回值
所以在我的application.properties
我:
application.donneeCommuneDossier=C\:\\test
application.destinationDonneeCommuneDossier=C\:\\dev\\repertoireDonneeCommune\\Cobol
我班FichierCommunRetriever
使用這些條目下面的代碼:
public class FichierCommunRetriever implements Runnable {
@Value("${application.donneeCommuneDossier}")
private String fichierCommunDossierPath;
@Value("${application.destinationDonneeCommuneDossier}")
private String destinationFichierCommunDossierPath;
}
我們正在加載application.properties
與類ApplicationConfig
下面的代碼:
@ImportResource("classpath:/com/folder/folder/folder/folder/folder/applicationContext.xml")
在ApplicationConfig
,我定義一個bean
,在一個新的線程像使用FichierCommunRetriever
:
Thread threadToExecuteTask = new Thread(new FichierCommunRetriever());
threadToExecuteTask.start();
我想我的問題是,因爲FichierCommunRetriever
在一個單獨的線程運行,類不能達到applicationContext
並且無法給出價值。
我想知道如果註釋會起作用,或者我必須改變我得到這些值的方式?
非常感謝它的工作完美。 – 2013-04-04 18:43:41