一、该问题的重现步骤是什么?
1. 使用@Component和@PostConstruct注解
2. 打包后用java -jar运行项目出现报错
3.
TestStartUpClass { INoticeService () { System..println()List<Notice> list = .list()list.forEach(System.::println)System..println()} }
二、你期待的结果是什么?实际看到的又是什么?
想要在项目运行后执行一个方法,进行查询数据库,然后再根据查到的数据创建定时任务。
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
SpringBlade,3.6.0RELEASE,Windows
四、请提供详细的错误堆栈信息,这很重要。
_____ _ ______ _ _
/ ___| (_) | ___ \| | | |
\ `--. _ __ _ __ _ _ __ __ _ | |_/ /| | __ _ __| | ___
`--. \| '_ \ | '__|| || '_ \ / _` | | ___ \| | / _` | / _` | / _ \
/\__/ /| |_) || | | || | | || (_| | | |_/ /| || (_| || (_| || __/
\____/ | .__/ |_| |_||_| |_| \__, | \____/ |_| \__,_| \__,_| \___|
| | __/ |
|_| |___/
:: SpringBlade :: blade-api:dev :: Running SpringBoot 2.7.10 ::
2023-08-24 14:31:18.913 INFO 10000 --- [ main] org.springblade.Application : Starting Application using Java 17.0.4.1 on slkj with PID 10000 (D:\work\workspace\娴嬭瘯椤圭洰\娴嬭瘯鍚姩鏂规硶\SpringBlade\target\SpringBlade.jar started by winke in D:\work\workspace\娴嬭瘯椤圭洰\娴嬭瘯鍚姩鏂规硶\SpringBlade\target)
2023-08-24 14:31:18.922 DEBUG 10000 --- [ main] org.springblade.Application : Running with Spring Boot v2.7.10, Spring v5.3.27
2023-08-24 14:31:18.923 INFO 10000 --- [ main] org.springblade.Application : The following 1 profile is active: "dev"
2023-08-24 14:31:18.949 INFO 10000 --- [kground-preinit] o.h.validator.internal.util.Version : HV000001: Hibernate Validator 6.2.5.Final
2023-08-24 14:31:21.519 INFO 10000 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2023-08-24 14:31:21.523 INFO 10000 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2023-08-24 14:31:21.607 INFO 10000 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 46 ms. Found 0 Redis repository interfaces.
2023-08-24 14:31:21.882 WARN 10000 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[org.springblade]' package. Please check your configuration.
2023-08-24 14:31:23.493 WARN 10000 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2023-08-24 14:31:23.543 INFO 10000 --- [ main] io.undertow.servlet : Initializing Spring embedded WebApplicationContext
2023-08-24 14:31:23.544 INFO 10000 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4541 ms
2023-08-24 14:31:23.786 INFO 10000 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2023-08-24 14:31:24.051 INFO 10000 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
测试在项目启动时执行方法
2023-08-24 14:31:27.307 DEBUG 10000 --- [ main] o.s.c.b.tenant.BladeTenantInterceptor : original SQL: SELECT id,title,category,release_time,content,create_user,create_time,update_user,update_time,status,is_deleted FROM blade_notice
WHERE is_deleted=0
2023-08-24 14:31:27.474 DEBUG 10000 --- [ main] o.s.c.b.tenant.BladeTenantInterceptor : SQL to parse, SQL: SELECT id,title,category,release_time,content,create_user,create_time,update_user,update_time,status,is_deleted FROM blade_notice
WHERE is_deleted=0
2023-08-24 14:31:27.488 DEBUG 10000 --- [ main] o.s.c.b.tenant.BladeTenantInterceptor : parse the finished SQL: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
2023-08-24 14:31:27.901 DEBUG 10000 --- [ main] o.s.m.d.mapper.NoticeMapper.selectList : ==> Preparing: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
2023-08-24 14:31:27.993 WARN 10000 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testStartUpClass': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
### The error may exist in org/springblade/modules/desk/mapper/NoticeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
2023-08-24 14:31:28.027 INFO 10000 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closing ...
2023-08-24 14:31:28.044 INFO 10000 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} closed
2023-08-24 14:31:28.066 INFO 10000 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-08-24 14:31:28.100 ERROR 10000 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testStartUpClass': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
### The error may exist in org/springblade/modules/desk/mapper/NoticeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:920)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:164)
at org.springblade.core.launch.BladeApplication.run(BladeApplication.java:49)
at org.springblade.Application.main(Application.java:33)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
### The error may exist in org/springblade/modules/desk/mapper/NoticeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at jdk.proxy2/jdk.proxy2.$Proxy127.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
at jdk.proxy2/jdk.proxy2.$Proxy152.selectList(Unknown Source)
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:370)
at com.baomidou.mybatisplus.extension.service.IService.list(IService.java:379)
at com.baomidou.mybatisplus.extension.service.IService$$FastClassBySpringCGLIB$$f8525d18.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:123)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at org.springblade.modules.desk.service.impl.NoticeServiceImpl$$EnhancerBySpringCGLIB$$174bd4d2.list(<generated>)
at org.springblade.modules.desk.controller.TestStartUpClass.startUpMethod(TestStartUpClass.java:23)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)
... 26 common frames omitted
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
### The error may exist in org/springblade/modules/desk/mapper/NoticeMapper.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id, title, category, release_time, content, create_user, create_time, update_user, update_time, status, is_deleted FROM blade_notice WHERE is_deleted = 0
### Cause: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:153)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
... 53 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.reflect.InvocationHandler java.lang.reflect.Proxy.h accessible: module java.base does not "opens java.lang.reflect" to unnamed module @6cd8737
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at org.apache.ibatis.reflection.invoker.GetFieldInvoker.invoke(GetFieldInvoker.java:38)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:164)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122)
at org.apache.ibatis.reflection.MetaObject.metaObjectForProperty(MetaObject.java:145)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:115)
at org.springblade.core.mp.plugins.SqlLogInterceptor.intercept(SqlLogInterceptor.java:46)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at jdk.proxy2/jdk.proxy2.$Proxy162.query(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at jdk.proxy2/jdk.proxy2.$Proxy161.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151)
... 60 common frames omitted
五、若有更多详细信息,请在下面提供。
不只是使用@Component和@PostConstruct注解会出现这个报错,使用ApplicationRunner或者在原来的Application中调用service查询数据库都会出现报错
扫一扫访问 Blade技术社区 移动端