在我的Spring boot application
我目前使用运行以下:Spring Boot应用程序:将应用程序分成独立的任务从命令行运行?
@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan("my.packages.to.scan")
@EnableScheduling
public class Scheduler {
public static void main(String[] args){
SpringApplication.run(Scheduler.class, args);
}
}
这则发现下面的类来运行:
@Component
public class MyApplication {
@Transactional
@Scheduled(fixedRate = 400000, initialDelay = 1000)
public void tasks() {
methodOne();
methodTwo();
methodThree();
}
public void methodOne() {
}
public void methodTwo() {
}
public void methodthree() {
}
}
正如从以上可以看出,我的应用程序运行所有3方法依次为。
我想变化我的应用程序,以便任何方法/任务可以在命令行中随时跑,而不是调用的主要方法和运行行中的所有三种方法。
我该怎么做?我需要从MyApplication类中移动我的方法吗?
您是否希望能够在应用程序的运行时期间运行任务,或者只能在启动时作为命令行中的参数运行? – dunni
我希望它们能够作为cmd行上的参数运行? – java123999