簡體   English   中英

沒有 rest controller 的 SpringBoot 應用程序

[英]SpringBoot application without a rest controller

我是 spring 的新手,我目前正在開發 spring 應用程序以在 2 個數據庫之間遷移數據。

我的問題是,它將如何運行? 我的意思是,使用 spring,如何讓 spring 知道遷移過程將從哪里開始?

例如,假設我有 3 個表(客戶、產品和發票)。

我將在課程上首先遷移來自客戶的所有數據,然后是產品,最后是發票。

我對 spring 在啟動時如何管理它感到困惑。

提前謝謝。

正如@Marged 所建議的那樣, CommandLineRunner應用程序只會實現您正在尋找的東西:

@SpringBootApplication
public class YourMigrationApplication implements CommandLineRunner {
 
    public static void main(String[] args) {
        // Application starts
        SpringApplication.run(SpringBootConsoleApplication.class, args);
        // Migration finished
    }
 
    @Override
    public void run(String... args) {
        // Migrate Customer data
        // Migrate Product data
        // Migrate Invoice data
    }
}

遷移發票數據步驟完成后,您的應用程序將退出,因為沒有任何東西可以運行。 (並且您沒有任何控制器等可以繼續收聽)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM