构造函数 TaskLaunchRequest(String, List<String>, null, null) 未定义 - Spring Cloud Task
The constructor TaskLaunchRequest(String, List<String>, null, null) is undefined - Spring Cloud Task
我正在使用 Spring Boot 为 Spring 云开发代码。在这个例子中,我在 Spring Cloud Tasks
工作。我正在使用 Spring Boot <version>1.4.1.RELEASE</version>
然后下面的代码工作正常。当我更新 <version>2.0.4.RELEASE</version>
时,出现以下错误。
The constructor TaskLaunchRequest(String, List, null, null) is undefined
TaskProcessor.java
@Component
@EnableBinding(Source.class)
public class TaskProcessor {
@Autowired
private Source source;
public void publishRequest(String payload) {
//maven://[groupid]:[artifactid]:jar:[version]
//String url = "maven://pluralsight.demo:pluralsight-springcloud-m3-task:jar:0.0.1-SNAPSHOT";
String url = "maven://pluralsight.demo:springcloud-m3-tasksink:jar:1.0";
List<String> input = new ArrayList<String>(Arrays.asList(payload.split(",")));
TaskLaunchRequest request = new TaskLaunchRequest(url, input, null, null);
System.out.println("created task launch request ...");
GenericMessage<TaskLaunchRequest> message = new GenericMessage<>(request);
this.source.output().send(message);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
<spring-cloud-task.version>2.0.0.RELEASE</spring-cloud-task.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>${spring-cloud-task.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
错误图片:
我遇到了同样的问题,在 pom 文件中进行了以下修改后,它可以正常工作。
替换你的:
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
与:
<spring-cloud.version>Brixton.SR6</spring-cloud.version>
替换你的:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
</dependency>
与:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-starter</artifactId>
<version>1.0.1.RELEASE</version>
</dependency>
我正在使用 Spring Boot 为 Spring 云开发代码。在这个例子中,我在 Spring Cloud Tasks
工作。我正在使用 Spring Boot <version>1.4.1.RELEASE</version>
然后下面的代码工作正常。当我更新 <version>2.0.4.RELEASE</version>
时,出现以下错误。
The constructor TaskLaunchRequest(String, List, null, null) is undefined
TaskProcessor.java
@Component
@EnableBinding(Source.class)
public class TaskProcessor {
@Autowired
private Source source;
public void publishRequest(String payload) {
//maven://[groupid]:[artifactid]:jar:[version]
//String url = "maven://pluralsight.demo:pluralsight-springcloud-m3-task:jar:0.0.1-SNAPSHOT";
String url = "maven://pluralsight.demo:springcloud-m3-tasksink:jar:1.0";
List<String> input = new ArrayList<String>(Arrays.asList(payload.split(",")));
TaskLaunchRequest request = new TaskLaunchRequest(url, input, null, null);
System.out.println("created task launch request ...");
GenericMessage<TaskLaunchRequest> message = new GenericMessage<>(request);
this.source.output().send(message);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
<spring-cloud-task.version>2.0.0.RELEASE</spring-cloud-task.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>${spring-cloud-task.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
错误图片:
我遇到了同样的问题,在 pom 文件中进行了以下修改后,它可以正常工作。
替换你的:
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
与:
<spring-cloud.version>Brixton.SR6</spring-cloud.version>
替换你的:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-task</artifactId> </dependency>
与:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-task-starter</artifactId> <version>1.0.1.RELEASE</version> </dependency>