错误: An SQL error occurred when executing the following query: .

本文介绍了一个常见的OpenCms数据库读取速度慢的问题,并提供了解决方案:通过修改opencms.properties文件中的配置,将db.pool.default.whenExhaustedAction的值从block改为grow。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


org.opencms.db.CmsDbSqlException: An SQL error occurred when executing the following query: .
at org.opencms.db.generic.CmsVfsDriver.readResource(CmsVfsDriver.java:1942)
at org.opencms.db.CmsDriverManager.readResource(CmsDriverManager.java:6462)
at org.opencms.db.CmsSecurityManager.readResource(CmsSecurityManager.java:5849)
at org.opencms.db.CmsSecurityManager.readResource(CmsSecurityManager.java:4034)
at org.opencms.file.CmsObject.readResource(CmsObject.java:3529)
.....


最近opencms老是出现读取数据库慢,半天刷新不出来,最后出现上面的异常.
看异常信息是数据库的问题,涉及到连接池.自己也不敢乱改.于是google,发现原来修改opencms.properties文件的一个配置就可以了,如下代码


# action to take when the pool is exhausted {grow|block|fail}
db.pool.default.whenExhaustedAction=block


[b][color=red]把 block 修改成 grow[/color][/b]
发现一个有趣的现象,在idea上运行ruoyisystemapplication类并没有报错,但是运行maven打包的jar包却会报错,错误是以下内容 java -jar ruoyi-modules-system.jar 14:11:09.271 [main] INFO c.a.n.c.e.SearchableProperties - [sortPropertySourceDefaultOrder,197] - properties search order:PROPERTIES->JVM->ENV->DEFAULT_SETTING 14:11:09.360 [background-preinit] INFO o.h.v.i.util.Version - [<clinit>,21] - HV000001: Hibernate Validator 6.2.5.Final Spring Boot Version: 2.7.18 Spring Application Name: ruoyi-system _ _ (_) | | _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ | '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ | | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | |_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| __/ | __/ | |___/ |___/ 14:11:10.476 [main] INFO c.a.n.p.a.s.c.ClientAuthPluginManager - [init,56] - [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success. 14:11:10.477 [main] INFO c.a.n.p.a.s.c.ClientAuthPluginManager - [init,56] - [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success. 14:11:11.896 [main] ERROR c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,114] - parse data from Nacos error,dataId:application-dev.yml,data:spring: autoconfigure: exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # feign 配置 feign: sentinel: enabled: true okhttp: enabled: true httpclient: enabled: false client: config: default: connectTimeout: 10000 readTimeout: 10000 compression: request: enabled: true min-request-size: 8192 response: enabled: true # 暴露监控端点 management: endpoints: web: exposure: include: '*' org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1 at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218) at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1218) at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:329) at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:251) at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:214) at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:166) at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:156) at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:93) at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:124) at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:509) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:199) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:166) at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:88) at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50) at com.alibaba.cloud.nacos.parser.NacosDataParserHandler.parseNacosData(NacosDataParserHandler.java:92) at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:107) at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:74) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosConfiguration(NacosPropertySourceLocator.java:158) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadSharedConfiguration(NacosPropertySourceLocator.java:116) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:101) at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:51) at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47) at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.doInitialize(PropertySourceBootstrapConfiguration.java:120) at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:110) at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:605) at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:374) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.ruoyi.system.RuoYiSystemApplication.main(RuoYiSystemApplication.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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: java.nio.charset.MalformedInputException: Input length = 1 at java.nio.charset.CoderResult.throwException(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183) ... 42 common frames omitted 14:11:11.970 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,97] - Ignore the empty nacos configuration and get it based on dataId[ruoyi-system] & group[DEFAULT_GROUP] 14:11:11.978 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,97] - Ignore the empty nacos configuration and get it based on dataId[ruoyi-system.yml] & group[DEFAULT_GROUP] 14:11:12.001 [main] ERROR c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,114] - parse data from Nacos error,dataId:ruoyi-system-dev.yml,data:# spring配置 spring: redis: host: localhost port: 6379 password: datasource: druid: stat-view-servlet: enabled: true loginUsername: ruoyi loginPassword: 123456 dynamic: druid: initial-size: 5 min-idle: 5 maxActive: 20 maxWait: 60000 connectTimeout: 30000 socketTimeout: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 filters: stat,slf4j connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: primary: true driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: 123456789 # 从库数据源 # slave: # username: # password: # url: # driver-class-name: # mybatisPlus配置 mybatis-plus: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.system # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath:mapper/system/*.xml # springdoc配置 springdoc: gatewayUrl: http://localhost:8080/${spring.application.name} api-docs: # 是否开启接口文档 enabled: true info: # 标题 title: '系统模块接口文档' # 描述 description: '系统模块接口描述' # 作者信息 contact: name: RuoYi url: https://ruoyi.vip org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1 at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:218) at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1218) at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:329) at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:251) at org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart.produce(ParserImpl.java:214) at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:166) at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:156) at org.yaml.snakeyaml.composer.Composer.checkNode(Composer.java:93) at org.yaml.snakeyaml.constructor.BaseConstructor.checkData(BaseConstructor.java:124) at org.yaml.snakeyaml.Yaml$1.hasNext(Yaml.java:509) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:199) at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:166) at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:88) at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50) at com.alibaba.cloud.nacos.parser.NacosDataParserHandler.parseNacosData(NacosDataParserHandler.java:92) at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.loadNacosData(NacosPropertySourceBuilder.java:107) at com.alibaba.cloud.nacos.client.NacosPropertySourceBuilder.build(NacosPropertySourceBuilder.java:74) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosPropertySource(NacosPropertySourceLocator.java:199) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadNacosDataIfPresent(NacosPropertySourceLocator.java:186) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.loadApplicationConfiguration(NacosPropertySourceLocator.java:149) at com.alibaba.cloud.nacos.client.NacosPropertySourceLocator.locate(NacosPropertySourceLocator.java:103) at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:51) at org.springframework.cloud.bootstrap.config.PropertySourceLocator.locateCollection(PropertySourceLocator.java:47) at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.doInitialize(PropertySourceBootstrapConfiguration.java:120) at org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration.initialize(PropertySourceBootstrapConfiguration.java:110) at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:605) at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:374) at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.ruoyi.system.RuoYiSystemApplication.main(RuoYiSystemApplication.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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: java.nio.charset.MalformedInputException: Input length = 1 at java.nio.charset.CoderResult.throwException(Unknown Source) at sun.nio.cs.StreamDecoder.implRead(Unknown Source) at sun.nio.cs.StreamDecoder.read(Unknown Source) at java.io.InputStreamReader.read(Unknown Source) at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:125) at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:183) ... 41 common frames omitted 14:11:12.033 [main] INFO c.r.s.RuoYiSystemApplication - [logStartupProfileInfo,638] - The following 1 profile is active: "dev" 14:11:14.961 [main] INFO o.a.c.h.Http11NioProtocol - [log,168] - Initializing ProtocolHandler ["http-nio-9201"] 14:11:14.964 [main] INFO o.a.c.c.StandardService - [log,168] - Starting service [Tomcat] 14:11:14.964 [main] INFO o.a.c.c.StandardEngine - [log,168] - Starting Servlet engine: [Apache Tomcat/9.0.105] 14:11:14.991 [main] WARN o.a.c.w.DirResourceSet - [log,168] - Disabled the global canonical file name cache to protect against CVE-2024-56337 when starting the WebResourceSet at [C:\Users\Administrator\AppData\Local\Temp\tomcat-docbase.9201.8258199422102733826] which is part of the web application [] 14:11:15.300 [main] INFO o.a.c.c.C.[.[.[/] - [log,168] - Initializing Spring embedded WebApplicationContext 14:11:15.478 [main] WARN c.b.d.d.DynamicRoutingDataSource - [afterPropertiesSet,243] - dynamic-datasource initial loaded [0] datasource,Please add your primary datasource or check your configuration 14:11:16.080 [main] WARN c.b.m.c.m.TableInfoHelper - [initTableFields,347] - Can not find table primary key in Class: "com.ruoyi.system.domain.SysConfig". 14:11:16.081 [main] WARN c.b.m.c.i.DefaultSqlInjector - [getMethodList,56] - class com.ruoyi.system.domain.SysConfig ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method. 14:11:16.134 [main] WARN c.b.m.c.m.TableInfoHelper - [initTableFields,347] - Can not find table primary key in Class: "com.ruoyi.system.api.domain.SysDept". 14:11:16.135 [main] WARN c.b.m.c.i.DefaultSqlInjector - [getMethodList,56] - class com.ruoyi.system.api.domain.SysDept ,Not found @TableId annotation, Cannot use Mybatis-Plus 'xxById' Method. _ _ |_ _ _|_. ___ _ | _ | | |\/|_)(_| | |_\ |_)||_|_\ / | 3.5.3.1 14:11:17.265 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - [refresh,599] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysConfigController': Unsatisfied de pendency expressed through field 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sys ConfigServiceImpl': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource ### The error may exist in URL [jar:file:/C:/Users/Administrator/Desktop/port_manage_system/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar!/BOOT-INF/classes!/mapper/system/SysConfigMapper.xml] ### The error may involve com.ruoyi.system.mapper.SysConfigMapper.selectConfigList ### The error occurred while executing a query ### Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource 14:11:17.289 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,215] - dynamic-datasource start closing .... 14:11:17.291 [main] INFO c.b.d.d.DynamicRoutingDataSource - [destroy,219] - dynamic-datasource all closed success,bye 14:11:17.295 [main] INFO o.a.c.c.StandardService - [log,168] - Stopping service [Tomcat] 14:11:17.409 [main] ERROR o.s.b.SpringApplication - [reportFailure,818] - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysConfigController': Unsatisfied dependency expressed through f ield 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource ### The error may exist in URL [jar:file:/C:/Users/Administrator/Desktop/port_manage_system/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar!/BOOT-INF/classes!/mapper/system/SysConfigMapper.xml] ### The error may involve com.ruoyi.system.mapper.SysConfigMapper.selectConfigList ### The error occurred while executing a query ### Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:713) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:693) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:408) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:209) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.ruoyi.system.RuoYiSystemApplication.main(RuoYiSystemApplication.java:22) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource ### The error may exist in URL [jar:file:/C:/Users/Administrator/Desktop/port_manage_system/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar!/BOOT-INF/classes!/mapper/system/SysConfigMapper.xml] ### The error may involve com.ruoyi.system.mapper.SysConfigMapper.selectConfigList ### The error occurred while executing a query ### Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource 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:336) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:209) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:710) ... 28 common frames omitted Caused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource ### The error may exist in URL [jar:file:/C:/Users/Administrator/Desktop/port_manage_system/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar!/BOOT-INF/classes!/mapper/system/SysConfigMapper.xml] ### The error may involve com.ruoyi.system.mapper.SysConfigMapper.selectConfigList ### The error occurred while executing a query ### Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:439) at com.sun.proxy.$Proxy128.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 com.sun.proxy.$Proxy134.selectConfigList(Unknown Source) at com.ruoyi.system.service.impl.SysConfigServiceImpl.loadingConfigCache(SysConfigServiceImpl.java:158) at com.ruoyi.system.service.impl.SysConfigServiceImpl.init(SysConfigServiceImpl.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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) ... 40 common frames omitted Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource ### The error may exist in URL [jar:file:/C:/Users/Administrator/Desktop/port_manage_system/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar!/BOOT-INF/classes!/mapper/system/SysConfigMapper.xml] ### The error may involve com.ruoyi.system.mapper.SysConfigMapper.selectConfigList ### The error occurred while executing a query ### Cause: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:156) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:142) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:425) ... 56 common frames omitted Caused by: com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException: dynamic-datasource can not find primary datasource at com.baomidou.dynamic.datasource.DynamicRoutingDataSource.determinePrimaryDataSource(DynamicRoutingDataSource.java:101) at com.baomidou.dynamic.datasource.DynamicRoutingDataSource.getDataSource(DynamicRoutingDataSource.java:130) at com.baomidou.dynamic.datasource.DynamicRoutingDataSource.determineDataSource(DynamicRoutingDataSource.java:87) at com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource.getConnection(AbstractRoutingDataSource.java:54) at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:160) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:118) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:81) at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80) at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:345) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:89) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:64) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:333) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:158) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:110) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59) at com.sun.proxy.$Proxy139.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:154) ... 63 common frames omitted 14:11:17.708 [Thread-8] WARN c.a.n.c.n.NotifyCenter - [shutdown,136] - [NotifyCenter] Start destroying Publisher 14:11:17.709 [Thread-8] WARN c.a.n.c.n.NotifyCenter - [shutdown,153] - [NotifyCenter] Destruction of the end 14:11:17.708 [Thread-3] WARN c.a.n.c.h.HttpClientBeanHolder - [shutdown,102] - [HttpClientBeanHolder] Start destroying common HttpClient 这是我的nacos配置 # spring配置 spring: redis: host: localhost port: 6379 password: datasource: druid: stat-view-servlet: enabled: true loginUsername: ruoyi loginPassword: 123456 dynamic: druid: initial-size: 5 min-idle: 5 maxActive: 20 maxWait: 60000 connectTimeout: 30000 socketTimeout: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 filters: stat,slf4j connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000 datasource: master: primary: true driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root password: 123456789 # 从库数据源 # slave: # username: # password: # url: # driver-class-name: # mybatisPlus配置 mybatis-plus: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.system # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath:mapper/system/*.xml # springdoc配置 springdoc: gatewayUrl: http://localhost:8080/${spring.application.name} api-docs: # 是否开启接口文档 enabled: true info: # 标题 title: '系统模块接口文档' # 描述 description: '系统模块接口描述' # 作者信息 contact: name: RuoYi url: https://ruoyi.vip 这是我的ruoyi-modules-system的pox.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-modules</artifactId> <version>3.6.6</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>ruoyi-modules-system</artifactId> <description> ruoyi-modules-system系统模块 </description> <dependencies> <!-- SpringCloud Alibaba Nacos --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency> <!-- SpringCloud Alibaba Nacos Config --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> </dependency> <!-- SpringCloud Alibaba Sentinel --> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> <!-- SpringBoot Actuator --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- Mysql Connector --> <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> </dependency> <!-- RuoYi Common DataSource --> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-datasource</artifactId> </dependency> <!-- RuoYi Common DataScope --> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-datascope</artifactId> </dependency> <!-- RuoYi Common Log --> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-log</artifactId> </dependency> <!-- RuoYi Common Swagger --> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-swagger</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> </dependency> </dependencies> <build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>
最新发布
06-11
<think>好的,我现在需要解决用户在Eclipse启动时遇到的错误:“An error has occurred. See the log file null”。首先,我需要了解这个错误的常见原因和解决方法。根据经验,这个错误通常与Eclipse的配置文件损坏、插件冲突或者工作空间问题有关。 首先,用户提到的日志文件路径显示为null,这可能意味着Eclipse无法正确找到或生成日志文件。这可能是因为工作空间未正确初始化或权限问题导致无法写入日志。我应该建议用户检查工作空间目录的权限,并尝试清理或重新创建工作空间。 接下来,用户提供的参考代码片段涉及到在Eclipse插件开发中创建项目和文件,这可能与问题没有直接关联。不过,代码中的`IWorkspace`和`IProject`操作可能提示了工作空间配置的问题。也许用户最近进行了插件开发或修改了工作空间设置,导致启动时出现错误。 然后,我需要考虑常见的解决方法步骤。例如,可以建议用户尝试使用`-clean`参数启动Eclipse,这可以清除缓存并重新初始化插件注册表。此外,检查Eclipse安装目录下的`.log`文件,但用户提到日志路径为null,可能需要手动指定日志路径或检查启动配置。 另外,用户可能安装了不兼容的插件,导致启动失败。可以建议在安全模式下启动Eclipse(使用`-safe`参数),然后禁用最近安装的插件。如果问题仍然存在,可能需要删除配置文件,例如删除`configuration`目录中的`org.eclipse.update`文件夹,或者重置整个配置。 还需要检查Java环境是否兼容,确保Eclipse使用的Java版本符合要求。有时候,更新Java或指定正确的JVM路径可以解决问题。此外,检查Eclipse的启动配置文件(如eclipse.ini)是否有错误的参数或内存设置不足。 最后,如果以上步骤无效,建议备份工作空间后重新安装Eclipse,或者尝试使用较旧或较新的版本。同时,提醒用户在操作前备份重要数据,避免数据丢失。</think>[逐步解决方案] 针对Eclipse启动错误"An error has occurred. See the log file null",请按以下步骤排查: 1. **基础排查** - 检查工作空间权限 - 确保工作空间路径不含特殊字符 - 验证磁盘剩余空间 > 1GB 2. **清理缓存启动** ```bash eclipse -clean -clearPersistedState ``` 这会重置插件注册表和运行时缓存[^1] 3. **日志定位** - 强制指定日志路径: ```bash eclipse -consoleLog -debug > /tmp/eclipse.log 2>&1 ``` - Windows系统默认日志位于: $$C:\Users\\{用户名}\\.eclipse\\{版本号}\\configuration\\*.log$$ 4. **配置文件重置** 删除以下目录后重启: ``` eclipse/configuration/org.eclipse.update eclipse/configuration/org.eclipse.osgi ``` 5. **插件冲突检测** ```bash eclipse -safe ``` 在安全模式中禁用最近安装的插件 6. **JVM环境验证** - 检查eclipse.ini中配置: ``` -vm C:/Program Files/Java/jdk1.8.0_291/bin/javaw.exe ``` - 确保Java版本匹配(推荐JDK8/JDK11) 7. **终极方案** ```bash mv workspace/.metadata .metadata.bak ``` 备份元数据后重建工作空间 [典型场景案例] 某开发者安装新插件后出现该错误,通过`eclipse -clean`命令成功启动。后发现是内存设置不足导致: ```ini # eclipse.ini修正后配置 -Xms1024m -Xmx2048m -XX:MaxPermSize=512m ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值