错误:找不到所需的类型为'org.springframework.batch.core.Job'的bean的现场作业

故障

我是Spring Batch的初学者,因此我开发了一个简单的项目。我得到了错误。

Description:
Field job in com.example.demo.DemoApplication required a bean of type 
'org.springframework.batch.core.Job' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.batch.core.Job' in your 
configuration.

这是我的代码,我只有一个类:

'package com.example.demo;


import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@SpringBootApplication
@EnableScheduling
@EnableBatchProcessing
public class DemoApplication {



@Autowired
private JobLauncher jobLauncher;


 @Autowired
 private Job job;

public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
}


 @Scheduled(cron = "0 */1 * * * ?")
    public void perform() throws Exception 
    {
        JobParameters params = new JobParametersBuilder()
                .addString("JobID", String.valueOf(System.currentTimeMillis()))
                .toJobParameters();
        jobLauncher.run(job, params);
    }

 }

感谢您帮助我找到此错误的主要原因

Mahmoud Ben Hassine

看来您没有Job在应用程序上下文中定义Bean,或者Spring Boot找不到该作业。

确保定义批处理作业的配置类是Spring Boot应用程序扫描的包(或子包)(com.example.demo根据您的示例)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

没有可用的“org.springframework.batch.core.Job”类型的合格 bean:预期单个匹配 bean,但发现 2:

来自分类Dev

现场的JdbcTemplate需要类型的bean的org.springframework.jdbc.core.JdbcTemplate'不能被发现

来自分类Dev

Spring Batch无法序列化以下类型的对象:类org.springframework.batch.core.StepExecution

来自分类Dev

找不到符合要求的类型为[org.springframework.social.twitter.api.Twitter]的合格Bean

来自分类Dev

没有类型为org.springframework.jdbc.core.JdbcTemplate的合格bean

来自分类Dev

找不到依赖项类型为[org.springframework.security.config.annotation.web.builders.HttpSecurity]的合格Bean

来自分类Dev

...中构造函数的参数0需要找不到类型为'org.springframework.web.client.RestTemplate'的bean

来自分类Dev

没有为org.springframework:org.springframework.core:3.2.2。下载文件。

来自分类Dev

没有枚举const类org.springframework.batch.core.JobParameter $ ParameterType.DATE-Informix

来自分类Dev

无法将[org.springframework.core.env.StandardEnvironment]类型的值转换为所需的类型

来自分类Dev

可以从JSP访问flowScope条目吗?(“在类型org.springframework.webflow.core.collection.LocalAttributeMap上找不到属性...”)

来自分类Dev

org.springframework.batch.item.file.FlatFileParseException:

来自分类Dev

RuntimeException的回滚:org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback; 错误的SQL语法[-Spring Batch问题

来自分类Dev

找不到 org.springframework.web.WebApplicationInitializer

来自分类Dev

org.springframework.beans.factory.CannotLoadBeanClassException:找不到名称为'的bean的类[com.Dao.ApplicationDaoImpl]

来自分类Dev

考虑重温项以上或配置中的定义类型的豆“org.springframework.data.redis.core.RedisTemplate”

来自分类Dev

我可以将org.springframework.security.core.userdetails.User扩展为程序中的实体吗?

来自分类Dev

春季错误:java.lang.NoClassDefFoundError:org / springframework / security / core / userdetails / memory / UserMap

来自分类Dev

引起原因:org.hibernate.MappingException:无法确定org.springframework.data.elasticsearch.core.geo.GeoPoint的类型

来自分类Dev

org.springframework.http.converter.HttpMessageNotWritableException 找不到类型为返回值的转换器:类

来自分类Dev

Bean初始化失败;嵌套的异常是java.lang.NoSuchFieldError:org / springframework / core / convert / TypeDescriptor.NULL

来自分类Dev

找不到名称为“ hibernate5AnnotatedSessionFactory”的bean的类[org.springframework.orm.hibernate5.LocalSessionFactoryBean]

来自分类Dev

错误启动:org.springframework.beans.factory.BeanCreationException:创建名称为bean的错误

来自分类Dev

错误启动:org.springframework.beans.factory.BeanCreationException:创建名称为bean的错误

来自分类Dev

没有'org.springframework.mail.javamail.JavaMailSender'类型的合格bean - Spring MVC

来自分类Dev

java.lang.ClassNotFoundException:org.springframework.core.io.Resource

来自分类Dev

java.lang.NoClassDefFoundError:org / springframework / core / env / ConfigurableEnvironment

来自分类Dev

Orika映射Spring的org.springframework.security.core.GrantedAuthority

来自分类Dev

测试applicationContext:org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes

Related 相关文章

  1. 1

    没有可用的“org.springframework.batch.core.Job”类型的合格 bean:预期单个匹配 bean,但发现 2:

  2. 2

    现场的JdbcTemplate需要类型的bean的org.springframework.jdbc.core.JdbcTemplate'不能被发现

  3. 3

    Spring Batch无法序列化以下类型的对象:类org.springframework.batch.core.StepExecution

  4. 4

    找不到符合要求的类型为[org.springframework.social.twitter.api.Twitter]的合格Bean

  5. 5

    没有类型为org.springframework.jdbc.core.JdbcTemplate的合格bean

  6. 6

    找不到依赖项类型为[org.springframework.security.config.annotation.web.builders.HttpSecurity]的合格Bean

  7. 7

    ...中构造函数的参数0需要找不到类型为'org.springframework.web.client.RestTemplate'的bean

  8. 8

    没有为org.springframework:org.springframework.core:3.2.2。下载文件。

  9. 9

    没有枚举const类org.springframework.batch.core.JobParameter $ ParameterType.DATE-Informix

  10. 10

    无法将[org.springframework.core.env.StandardEnvironment]类型的值转换为所需的类型

  11. 11

    可以从JSP访问flowScope条目吗?(“在类型org.springframework.webflow.core.collection.LocalAttributeMap上找不到属性...”)

  12. 12

    org.springframework.batch.item.file.FlatFileParseException:

  13. 13

    RuntimeException的回滚:org.springframework.jdbc.BadSqlGrammarException:PreparedStatementCallback; 错误的SQL语法[-Spring Batch问题

  14. 14

    找不到 org.springframework.web.WebApplicationInitializer

  15. 15

    org.springframework.beans.factory.CannotLoadBeanClassException:找不到名称为'的bean的类[com.Dao.ApplicationDaoImpl]

  16. 16

    考虑重温项以上或配置中的定义类型的豆“org.springframework.data.redis.core.RedisTemplate”

  17. 17

    我可以将org.springframework.security.core.userdetails.User扩展为程序中的实体吗?

  18. 18

    春季错误:java.lang.NoClassDefFoundError:org / springframework / security / core / userdetails / memory / UserMap

  19. 19

    引起原因:org.hibernate.MappingException:无法确定org.springframework.data.elasticsearch.core.geo.GeoPoint的类型

  20. 20

    org.springframework.http.converter.HttpMessageNotWritableException 找不到类型为返回值的转换器:类

  21. 21

    Bean初始化失败;嵌套的异常是java.lang.NoSuchFieldError:org / springframework / core / convert / TypeDescriptor.NULL

  22. 22

    找不到名称为“ hibernate5AnnotatedSessionFactory”的bean的类[org.springframework.orm.hibernate5.LocalSessionFactoryBean]

  23. 23

    错误启动:org.springframework.beans.factory.BeanCreationException:创建名称为bean的错误

  24. 24

    错误启动:org.springframework.beans.factory.BeanCreationException:创建名称为bean的错误

  25. 25

    没有'org.springframework.mail.javamail.JavaMailSender'类型的合格bean - Spring MVC

  26. 26

    java.lang.ClassNotFoundException:org.springframework.core.io.Resource

  27. 27

    java.lang.NoClassDefFoundError:org / springframework / core / env / ConfigurableEnvironment

  28. 28

    Orika映射Spring的org.springframework.security.core.GrantedAuthority

  29. 29

    测试applicationContext:org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes

热门标签

归档