jboss上的Spring启动部署问题

时间:2022-11-01 00:03:06

After deploying spring boot project on jboss ,every things work great except my schdule task.i have annotated my main class with @enablescheduling and @component on my schedule method class and @scheduled on my method.but after running successfuly without error on jboss ,my schedule task does not fire.i really need a solution. Tnx every body Below is my config class and my schedule classes:

在jboss上部署spring boot项目之后,除了我的程序任务之外,每个东西都工作得很好。我在我的schedule方法类中使用@enablescheduling和@component注释了我的主类,并在我的方法上注册了@scheduled。但是在jboss上成功运行后没有错误,我的日程安排任务没有开火。我真的需要一个解决方案。 Tnx every body下面是我的配置类和我的日程安排类:

@SpringBootApplicatio
@Enablescheduling
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
      SpringApplication.run(Application.class);              

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}
}

@component
Public class test{
@scheduled(fixedDelay = 1000)
Public void print(){
//do sth
}

}

2 个解决方案

#1


0  

@SpringBootApplicatio
@Enablescheduling
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
      SpringApplication.run(Application.class);              

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}
}

@component
Public class test{
@scheduled(fixeddelay.....)
Public void print(){
//do sth
}

}

#2


0  

Ok, we've found an issue. Setting initialDelay to 10000 ms resolved the problem in our case. Don't know an explanation but still: it works.

好的,我们发现了一个问题。将initialDelay设置为10000毫秒解决了我们的问题。不知道解释但仍然:它有效。

#1


0  

@SpringBootApplicatio
@Enablescheduling
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
      SpringApplication.run(Application.class);              

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
}
}

@component
Public class test{
@scheduled(fixeddelay.....)
Public void print(){
//do sth
}

}

#2


0  

Ok, we've found an issue. Setting initialDelay to 10000 ms resolved the problem in our case. Don't know an explanation but still: it works.

好的,我们发现了一个问题。将initialDelay设置为10000毫秒解决了我们的问题。不知道解释但仍然:它有效。