引发NoClassDefFoundError的示例项目:com / fasterxml / jackson / databind / ObjectMapper

时间:2019-05-29 18:24:26

标签: spring-batch

我已经按照https://spring.io/guides/gs/batch-processing/

实施了该项目

但是我得到了:

创建名称为'batchConfigurer'的bean时出错:调用init方法失败;嵌套的异常是java.lang.NoClassDefFoundError:com / fasterxml / jackson / databind / ObjectMapper

我是新手 谁能帮忙

2 个答案:

答案 0 :(得分:0)

以下内容按预期工作:

$>git clone https://github.com/spring-guides/gs-batch-processing.git
$>cd gs-batch-processing/complete
$>./mvnw clean install
$>./mvnw spring-boot:run

输出如下:

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

2019-05-30 12:23:12.642  INFO 90644 --- [           main] hello.Application                        : Starting Application on localhost with PID 90644 (/private/tmp/gs-batch-processing/complete/target/classes started by mbenhassine in /private/tmp/gs-batch-processing/complete)
2019-05-30 12:23:12.646  INFO 90644 --- [           main] hello.Application                        : No active profile set, falling back to default profiles: default
2019-05-30 12:23:13.333  INFO 90644 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-05-30 12:23:13.338  WARN 90644 --- [           main] com.zaxxer.hikari.util.DriverDataSource  : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation.
2019-05-30 12:23:13.683  INFO 90644 --- [           main] com.zaxxer.hikari.pool.PoolBase          : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2019-05-30 12:23:13.687  INFO 90644 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2019-05-30 12:23:14.091  INFO 90644 --- [           main] o.s.b.c.r.s.JobRepositoryFactoryBean     : No database type set, using meta data indicating: HSQL
2019-05-30 12:23:14.277  INFO 90644 --- [           main] o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, defaulting to synchronous executor.
2019-05-30 12:23:14.437  INFO 90644 --- [           main] hello.Application                        : Started Application in 2.114 seconds (JVM running for 5.2)
2019-05-30 12:23:14.438  INFO 90644 --- [           main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: []
2019-05-30 12:23:14.503  INFO 90644 --- [           main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=importUserJob]] launched with the following parameters: [{run.id=1}]
2019-05-30 12:23:14.530  INFO 90644 --- [           main] o.s.batch.core.job.SimpleStepHandler     : Executing step: [step1]
2019-05-30 12:23:14.590  INFO 90644 --- [           main] hello.PersonItemProcessor                : Converting (firstName: Jill, lastName: Doe) into (firstName: JILL, lastName: DOE)
2019-05-30 12:23:14.590  INFO 90644 --- [           main] hello.PersonItemProcessor                : Converting (firstName: Joe, lastName: Doe) into (firstName: JOE, lastName: DOE)
2019-05-30 12:23:14.590  INFO 90644 --- [           main] hello.PersonItemProcessor                : Converting (firstName: Justin, lastName: Doe) into (firstName: JUSTIN, lastName: DOE)
2019-05-30 12:23:14.590  INFO 90644 --- [           main] hello.PersonItemProcessor                : Converting (firstName: Jane, lastName: Doe) into (firstName: JANE, lastName: DOE)
2019-05-30 12:23:14.590  INFO 90644 --- [           main] hello.PersonItemProcessor                : Converting (firstName: John, lastName: Doe) into (firstName: JOHN, lastName: DOE)
2019-05-30 12:23:14.604  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : !!! JOB FINISHED! Time to verify the results
2019-05-30 12:23:14.607  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : Found <firstName: JILL, lastName: DOE> in the database.
2019-05-30 12:23:14.607  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : Found <firstName: JOE, lastName: DOE> in the database.
2019-05-30 12:23:14.607  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : Found <firstName: JUSTIN, lastName: DOE> in the database.
2019-05-30 12:23:14.607  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : Found <firstName: JANE, lastName: DOE> in the database.
2019-05-30 12:23:14.607  INFO 90644 --- [           main] hello.JobCompletionNotificationListener  : Found <firstName: JOHN, lastName: DOE> in the database.
2019-05-30 12:23:14.610  INFO 90644 --- [           main] o.s.b.c.l.support.SimpleJobLauncher      : Job: [FlowJob: [name=importUserJob]] completed with the following parameters: [{run.id=1}] and the following status: [COMPLETED]

如您所见,没有NoClassDefFoundError

答案 1 :(得分:0)

2个罐子被破坏,杰克逊数据绑定和log4。

虽然日志中的mvn全新安装错误为(invalid LOC header bad signature),但是构建成功,因此我错过了日志。

我不得不从.m2中删除该文件夹,然后运行mvn clean install这解决了问题