小编Mat*_*e.N的帖子

Spring Boot应用程序的@PostConstruct方法中的死锁

我正在使用Spring TaskScheduler在应用程序启动时安排任务(显然是……)。

TaskScheduler在我的SpringConfig中创建:

@Configuration
@EnableTransactionManagement
public class SpringConfig {

    @Bean
    public TaskScheduler taskScheduler() {
        return new ThreadPoolTaskScheduler();
    }

}
Run Code Online (Sandbox Code Playgroud)

spring boot应用程序在我的Main.class中启动,并安排任务@PostConstruct

@SpringBootApplication
@ComponentScan("...")
@EntityScan("...")
@EnableJpaRepositories("... .repositories")
@EnableAutoConfiguration
@PropertySources(value = {@PropertySource("classpath:application.properties")})
public class Main {

    private final static Logger LOGGER = LoggerFactory.getLogger(Main.class);

    private static SpringApplication application = new SpringApplication(Main.class);

    private TaskScheduler taskScheduler;

    private AnalysisCleaningThread cleaningThread;

    @Inject
    public void setCleaningThread(AnalysisCleaningThread cleaningThread) {
        this.cleaningThread = cleaningThread;
    }

    @Inject
    public void setTaskScheduler(TaskScheduler taskScheduler) {
        this.taskScheduler = taskScheduler;
    }

    public static void main(String[] args)
            throws …
Run Code Online (Sandbox Code Playgroud)

java spring future spring-data-jpa taskscheduler

4
推荐指数
1
解决办法
725
查看次数

标签 统计

future ×1

java ×1

spring ×1

spring-data-jpa ×1

taskscheduler ×1