我有一个类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