使用Quartz出现同包下的文件无法访问的异常

异常简明信息: See nested exception: java.lang.IllegalAccessException: class org.quartz.simpl.SimpleJobFactory (in module quartz) cannot access class com.soe.others.HelloJob (in module Thread_study05) because module Thread_study05 does not export com.soe.others to module quartz]

问题大致描述:quartz不能访问我的包com.soe.others中的文件 导致出现异常

问题出现原因 :ava9以后有一个管理模块的文件 module-info.java 所有需要的模块都必须在这里进行声明才能使用

解决方法 将编译器中提到的无法访问的包的名字在module-info.java文件中 在module块中使用关键字 exports 导入
示例:
exports com.soe.others;

详细异常信息

[ERROR] 18 2月 11:14:32.004 上午 DefaultQuartzScheduler_QuartzSchedulerThread [org.quartz.core.ErrorLogger]
An error occured instantiating job to be executed. job= 'group1.job1'

org.quartz.SchedulerException: Problem instantiating class 'com.soe.others.HelloJob' [See nested exception: java.lang.IllegalAccessException: class org.quartz.simpl.SimpleJobFactory (in module quartz) cannot access class com.soe.others.HelloJob (in module Thread_study05) because module Thread_study05 does not export com.soe.others to module quartz]
	at [email protected]/org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:60)
	at [email protected]/org.quartz.simpl.PropertySettingJobFactory.newJob(PropertySettingJobFactory.java:69)
	at [email protected]/org.quartz.core.JobRunShell.initialize(JobRunShell.java:127)
	at [email protected]/org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:392)
Caused by: java.lang.IllegalAccessException: class org.quartz.simpl.SimpleJobFactory (in module quartz) cannot access class com.soe.others.HelloJob (in module Thread_study05) because module Thread_study05 does not export com.soe.others to module quartz
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:639)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:490)
	at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)
	at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)
	at java.base/java.lang.Class.newInstance(Class.java:590)
	at [email protected]/org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:56)
	... 3 more

附module-info.java的另一位博主的详细说明
(转)https://blog.csdn.net/qq_43472877/article/details/104171769

你可能感兴趣的:(使用Quartz出现同包下的文件无法访问的异常)