org.springframework.cloud.task.launcher.TaskLaunch

2019-08-27 15:27发布

问题:

I am trying to run spring cloud task rabbitmq, but I am receiving errors as follows:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.4.RELEASE)

2018-08-14 16:54:53.674  INFO 6676 --- [           main] lsightSpringcloudM3TaskintakeApplication : Starting PluralsightSpringcloudM3TaskintakeApplication on P2BLAP-FG4DVP2 with PID 6676 (pluralsight-springcloud-m3-taskintake\target\classes started by .. in C.. /pluralsight-springcloud-m3-taskintake)
2018-08-14 16:54:53.681  INFO 6676 --- [           main] lsightSpringcloudM3TaskintakeApplication : No active profile set, falling back to default profiles: default
2018-08-14 16:54:53.745  INFO 6676 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6ae5aa72: startup date [Tue Aug 14 16:54:53 IST 2018]; root of context hierarchy
2018-08-14 16:54:54.405  INFO 6676 --- [           main] o.s.i.config.IntegrationRegistrar        : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2018-08-14 16:54:54.421  INFO 6676 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'taskProcessor' with a different definition: replacing [Generic bean: class [pluralsight.demo.TaskProcessor]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:\Users\prabin.tripathi\STS\sts-bundle\projects\pluralsight-springcloud-m3-taskintake\target\classes\pluralsight\demo\TaskProcessor.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=taskConfig; factoryMethodName=taskProcessor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [pluralsight/demo/TaskConfig.class]]
2018-08-14 16:54:54.835  INFO 6676 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2018-08-14 16:54:54.837  INFO 6676 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2018-08-14 16:54:54.980  INFO 6676 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$45205f62] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-14 16:54:55.073  INFO 6676 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration$$EnhancerBySpringCGLIB$$e9a65c63] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-14 16:54:55.588  INFO 6676 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8082 (http)
2018-08-14 16:54:55.611  INFO 6676 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-08-14 16:54:55.611  INFO 6676 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-08-14 16:54:55.616  INFO 6676 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_131\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre1.8.0_131/bin/server;C:/Program Files/Java/jre1.8.0_131/bin;C:/Program Files/Java/jre1.8.0_131/lib/amd64;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\TortoiseSVN\bin;C:\Program Files\PuTTY\;C:\Users\prabin.tripathi\projects\R45\pba\pba_build\env\dev\Maven\maven-2.0.7\bin;C:\Program Files\Java\jdk1.8.0_131\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files\Git\cmd;C:\HashiCorp\Vagrant\bin;C:\Users\prabin.tripathi\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\prabin.tripathi\AppData\Roaming\npm;C:\Users\prabin.tripathi\AppData\Local\GitHubDesktop\bin;C:\Users\prabin.tripathi\STS\sts-bundle\sts-3.9.5.RELEASE;;.]
2018-08-14 16:54:55.821  INFO 6676 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-08-14 16:54:55.821  INFO 6676 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2081 ms
2018-08-14 16:54:55.935  INFO 6676 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-08-14 16:54:55.941  INFO 6676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-14 16:54:55.941  INFO 6676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-14 16:54:55.941  INFO 6676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-14 16:54:55.941  INFO 6676 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-14 16:54:56.415  INFO 6676 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService  'taskScheduler'
2018-08-14 16:54:56.468  WARN 6676 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.task.launcher.TaskLauncherSink': Unsatisfied dependency expressed through field 'taskLauncher'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.deployer.spi.task.TaskLauncher' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-08-14 16:54:56.468  INFO 6676 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Shutting down ExecutorService 'taskScheduler'
2018-08-14 16:54:56.472  INFO 6676 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-08-14 16:54:56.485  INFO 6676 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-08-14 16:54:56.653 ERROR 6676 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field taskLauncher in org.springframework.cloud.task.launcher.TaskLauncherSink required a bean of type 'org.springframework.cloud.deployer.spi.task.TaskLauncher' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.cloud.deployer.spi.task.TaskLauncher' in your configuration.

My POM.xml is as follows:

<?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>

<groupId>pluralsight.demo</groupId>
<artifactId>pluralsight-springcloud-m3-taskintake</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>pluralsight-springcloud-m3-taskintake</name>
<description>task intake mrociservcies</description>

<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-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.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <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>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

application.properties is as follows:

server:
  port: 8082
spring:
  rabbitmq:
    username: ****
    password: ****
    host: localhost
    port: 5672
  cloud:
    stream:
      bindings:
        input:
          destination: tasktopic

回答1:

I just faced the same issue and I solved it looking at Task Launcher Local example. The thing I needed to do is to add deployer local dependency to my pom file.

In particular, adding the following sentence resolved the issue:

     <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-deployer-local</artifactId>
        <version>1.3.7.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>


回答2:

I faced same issue and fixed with this part of pom.xml

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-task</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-deployer-local</artifactId>
            <version>1.3.7.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-stream-test-support</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>
        </dependencies>
    </dependencyManagement>