[英]Spring cloud Dataflow Failed to start bean 'taskLifecycleListener'; nested exception is java.lang.IllegalArgumentException: Invalid TaskExecution
[英]Failed to start bean 'taskLifecycleListener'; nested exception is java.lang.IllegalArgumentException: Invalid TaskExecution, ID 1 not found
我正在使用 spring boot 項目並制作為 @Enabletask 並嘗試使用 spring 數據流運行。
我安裝了 spring 數據流服務器,在 shell 中我嘗試注冊應用程序並創建任務,當我運行任務時出現錯誤。
默認情況下,它使用 H2 數據庫,但我也嘗試使用 mysql,但面臨同樣的問題。
由於 java.lang.IllegalArgumentException: Invalid TaskExecution, ID 1 not found, 應用程序無法運行,我無法在 localhost:9393/ 上看到開始時間、結束時間和退出代碼
1) 使用 mysql 連接參數運行數據流服務器。 --spring.datasource.url=jdbc:mysql://localhost:3306/mydb --spring.datasource.username=root --spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
2) 使用 mysql 連接參數運行數據流 shell。 --spring.datasource.url=jdbc:mysql://localhost:3306/mydb --spring.datasource.username=root --spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
3)使用mysql連接參數執行任務。 --spring.datasource.url=jdbc:mysql://localhost:3306/mydb --spring.datasource.username=root --spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
已經在 pom 文件中添加了 mysql 依賴項。
請在下面找到主類的代碼
package com.example.demo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
@SpringBootApplication
@EnableTask
public class test {
@Bean
public CommandLineRunner commandLineRunner() {
return new HelloWorldCommandLineRunner();
}
public static void main(String[] args) {
SpringApplication.run(test.class, args);
}
public static class HelloWorldCommandLineRunner implements CommandLineRunner {
@Override
public void run(String... strings) throws Exception {
System.out.println("Hello, World!");
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<!-- <spring-cloud.version>Greenwich.SR1</spring-cloud.version> -->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
<version>1.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
你需要依賴 spring-boot-starter-jdbc 嗎? 也是 mariadb 驅動程序。 我假設 mysql 服務器正在運行。 檢查日志文件是否有較早的錯誤。
我有一個類似的問題,我在 github 上報告過。 https://github.com/spring-cloud/spring-cloud-task/issues/446
我的問題是 spring boot 和 spring cloud 版本。 正如我在您的情況中所看到的,您使用的是 spring boot 2.0.5 RELEASE,而對於 spring cloud task starter,您使用的是 1.2.3 RELEASE。 這可能會導致兼容性問題。
我建議您嘗試該依賴項的更新版本,您可以在此處找到該依賴項 - https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-task
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-task -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
1.xx 版本的 spring cloud starter task 兼容 1.xx 版本的 spring boot,同樣 2.xx 將兼容 2.xx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.