首页 > 数据库 >若依-更换数据库-sqlite

若依-更换数据库-sqlite

时间:2023-02-02 13:57:46浏览次数:65  
标签:sqlite java 数据库 factory springframework 若依 beans SpringApplication org

基础

我是在ruoyi-vue已经安装了mybatis-plus的基础上进行的修改

关于SQLite

SQLite 是一个软件库,实现了自给自足的、无服务器的、零配置的、事务性的 SQL 数据库引擎。
SQLite主页:https://www.sqlite.org/index.html

1. pom.xml

<!-- web启动插件 -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--lombok插件-->
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <optional>true</optional>
</dependency>
<!-- sqlite3驱动包 -->
<dependency>
  <groupId>org.xerial</groupId>
  <artifactId>sqlite-jdbc</artifactId>
  <version>3.21.0.1</version>
</dependency>
<!--mybatis-plus插件-->
<dependency>
  <groupId>com.baomidou</groupId>
  <artifactId>mybatis-plus-boot-starter</artifactId>
  <version>3.4.3.1</version>
</dependency>

2.application-druid.yml

2.1

# 数据源配置
spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        driverClassName: org.sqlite.JDBC
        druid:
            # 主库数据源
            master:
                url: jdbc:sqlite:db\\db.sqlite3?date_string_format=yyyy-MM-dd HH:mm:ss
                username:
                password:

注意: date_string_format=yyyy-MM-dd HH:mm:ss 必须添加否则有时会导致查询是报错

13:53:38.671 [restartedMain] ERROR o.s.b.SpringApplication - [reportFailure,870] - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'captchaController': Unsatisfied dependency expressed through field 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: Error attempting to get column 'create_time' from result set.  Cause: java.sql.SQLException: Error parsing time stamp
; uncategorized SQLException; SQL state [null]; error code [0]; Error parsing time stamp; nested exception is java.sql.SQLException: Error parsing time stamp
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	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: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:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:453)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:343)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1370)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1359)
	at com.ruoyi.RuoYiApplication.main(RuoYiApplication.java:18)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.sql.SQLException: Error parsing time stamp

2.2

	# 配置检测连接是否有效
	validationQuery: SELECT 1 FROM sys_config

3.MybatisPlusConfig

	/**
	 * 分页插件,自动识别数据库类型 https://baomidou.com/guide/interceptor-pagination.html
	 */
	public PaginationInnerInterceptor paginationInnerInterceptor()
	{
		PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
		// 设置数据库类型为mysql
		paginationInnerInterceptor.setDbType(DbType.SQLITE);
		// 设置最大单页限制数量,默认 500 条,-1 不受限制
		paginationInnerInterceptor.setMaxLimit(-1L);
		return paginationInnerInterceptor;
	}

4.mysql表数据结构转移为sqlite表结构及数据

我在这里分享一份我整理好的 可能版本会有点旧 到时候缺字段在补充吧
链接:https://pan.baidu.com/s/19UFOhYv0qTpRZgoAsjFj2g 
提取码:pwc2

标签:sqlite,java,数据库,factory,springframework,若依,beans,SpringApplication,org
From: https://www.cnblogs.com/-zhiwei-/p/17085753.html

相关文章

  • 08-数据库信息展示
    数据信息展示#知识点:#1.获取数据库所有内容list=PersonInfo.objects.all()#2.html中的for循环{%forlsinlist%}<tr><td>{......
  • Springboot数据库配置文件加密
    引入工具依赖包:!--配置文件加密--><dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>1.......
  • Blazor入门100天 : 身份验证和授权 (3) - DB改Sqlite
    目录建立默认带身份验证Blazor程序角色/组件/特性/过程逻辑DB改Sqlite将自定义字段添加到用户表脚手架拉取IDS文件,本地化资源freesql生成实体类,freesql管理......
  • 关于xxl-job中的慢sql引发的磁盘I/O飙升导致拖垮整个数据库服务
    背景:某天突然发现服务探测接口疯狂告警、同时数据库CPU消耗也告警,最后系统都无法访问;查看服务端日志,发现大量的报错如下:CommunicationsException:Communicationslink......
  • 大数据实时多维OLAP分析数据库Apache Druid入门分享-下
    @目录架构核心架构外部依赖核心内容roll-up预聚合列式存储Datasource和Segments位图索引数据摄取查询集群部署部署规划前置条件MySQL配置HDFS配置Zookeeper配置启动集群导......
  • 关系型数据库概述
    关系型数据库概述数据库的简介数据库是按照数据结构来组织、存储和管理数据的仓库,是一个长期存储在计算机内,有组织的、可共享的、统一管理的大量数据的集合。数据库的分......
  • Python连接MySQL数据库
    Python连接MySQL数据库安装MySQL参考链接安装NavicatPremium16参考链接连接MySQL安装库pipinstallpymysqlMySQL封装#!/usr/bin/envpython#-*-coding:ut......
  • 查询达梦数据库所有表的各种约束和索引
    查询DM数据库所有表的各种约束和索引--查询主键SELECTa.OWNERas"模式名",a.TABLE_NAMEas"表名",b.COLUMN_NAMEas"列名",a.CONSTRAINT_NAMEas"约束名"fromDBA......
  • 数据库分库分表-水平分片与垂直分片
    水平分片与垂直分片垂直分片:​ 按照业务维度将表拆到不同的数据库中,专库专用,分担数据库压力​ 缺点:单表数据量大时,无法解决数据库访问慢的问题水平分片:​ 按照某种规......
  • 2022下半年盘点:国产数据库重大更新及技术要点汇总
    2022下半年行业回顾云原生、分布式发展如火如荼2022年,数据库行业发展迅速,并呈现出若干鲜明特点。各数据库厂商及产品均取得长足进步,在部分重点技术领域有所突破,其中以国产......