gpt4 book ai didi

使用 Spring Batch 获取执行列表时出现 java.lang.IllegalAccessError

转载 作者:太空宇宙 更新时间:2023-11-04 11:17:20 25 4
gpt4 key购买 nike

我在尝试运行 Spring Batch 来加载执行列表时收到此错误。

java.lang.IllegalAccessError: tried to access method org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.getJobParameters(Ljava/lang/Long;)Lorg/springframework/batch/core/JobParameters; from class org.springframework.batch.admin.service.JdbcSearchableJobExecutionDao

经过一些分析,我发现 JdbcJobExecutionDao 是 Spring-batch 的一部分,并且将 getJobParameters() 的实现作为 protected 方法,而 JdbcSearchableJobExecutionDao 是 spring-batch-admin 的一部分,它扩展了 JdbcJobExecutionDao。

根据 Oracle 文档,它说 IllegalAccessError 是 -

Thrown if an application attempts to access or modify a field or to call a method that it does not have access to.

Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

我不明白,我无法控制这些 jar /类。我在使用它们时做错了什么吗?或者我用于这两个 jar 的版本是否有问题。

spring-batch - 版本 2.2.0.RELEASE

spring-batch-admin - 版本 1.3.0.BUILD-SNAPSHOT(也尝试过 1.3.0.RELEASE)

引用网站 - java.lang.IllegalAccessError: tried to access method

https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobExecutionDao.java

https://github.com/spring-projects/spring-batch-admin/blob/master/spring-batch-admin-manager/src/main/java/org/springframework/batch/admin/service/JdbcSearchableJobExecutionDao.java

最佳答案

所以,我通过使用正确的版本修复了这个问题。这是 spring-batch 和 spring-batch-admin 之间的版本不匹配问题。我引用了这个 spring 文档网站并尝试了推荐的版本,它成功了!

http://docs.spring.io/spring-batch-admin/spring-batch-admin-manager/dependencies.html

所以,现在我正在使用

2.2.7.RELEASE(Spring-Batch)

1.3.1.RELEASE(Spring-Batch-Admin)

并且我不再收到java.lang.IllegalAccessError。需要检查是否有任何其他功能受到干扰,因为这是一个非常老的项目。

希望这可以帮助面临类似问题的人。

关于使用 Spring Batch 获取执行列表时出现 java.lang.IllegalAccessError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45309329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com