使用弹簧靴的线程

时间:2015-04-28 15:02:13

标签: java spring-boot

我正在使用spring boot,我有一些类服务和控制器,现在我想创建一个线程来验证文件夹是否包含文件?我创建了用于验证文件存在的类,但现在我想将此类与spring boot集成。这是我的代码:

public class Linstenerfile implements Runnable{
String fichier ="C:/Project/containerFiles/snapshot.txt";
ControlleurFile l =new ControlleurFile();
File file = new File(fichier);
@Override
public void run() {
    // TODO Auto-generated method stub
    while(true)
    { 
        if(file.exists())
        {
             try {
                File Subscriberoffref=l.CreateSubscripberFile(file,"data");
                List<AbonneOffreDTO1> suscriberOffredata=l.GetCvsData(Subscriberoffref);
                l.VerifyData(suscriberOffredata);
                //  file.delete();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
        else
        {
        System.out.println("thread running");
        }
    }
}

}

这是springboot类应用程序:

@SpringBootApplication
public class GateWayProjectApplication {


public static void main(String[] args)   {

    SpringApplication.run(GateWayProjectApplication.class, args);
    Linstenerfile k =new Linstenerfile();
    k.run();
}

这是代码verifydata方法

public void VerifyData(List<AbonneOffreDTO1> lisaboff)
    {   
        System.out.println(abonneservice.GetAbonnesize());
    }

0 个答案:

没有答案