SpringBoot整合Sqlite数据库流程

1.创建项目

  方式一: 通过网站https://start.spring.io/

  方式二: 通过开发工具(IDEA或者Eclipse自行百度)

2.修改pom.xml配置文件,添加必要的驱动包

1<?xml version="1.0" encoding="UTF-8"?> 2<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-parent</artifactId> 8 <version>2.1.3.RELEASE</version> 9 <relativePath/> <!-- lookup parent from repository --> 10 </parent> 11 <groupId>com.xuanyin</groupId> 12 <artifactId>homektv</artifactId> 13 <version>0.0.1-SNAPSHOT</version> 14 <packaging>jar</packaging> 15 <!-- 统一管理jar包版本 --> 16 <properties> 17 <java.version>12</java.version> 18 <mybatis.spring.boot.version>2.0.0</mybatis.spring.boot.version> 19 <sqlite.jdbc.version>3.27.2.1</sqlite.jdbc.version> 20 </properties> 21 22 <dependencies> 23 <dependency> 24 <groupId>org.springframework.boot</groupId> 25 <artifactId>spring-boot-starter-web</artifactId> 26 </dependency> 27 <dependency> 28 <groupId>org.mybatis.spring.boot</groupId> 29 <artifactId>mybatis-spring-boot-starter</artifactId> 30 <version>${mybatis.spring.boot.version}</version> 31 </dependency> 32 <dependency> 33 <groupId>org.springframework.boot</groupId> 34 <artifactId>spring-boot-starter-test</artifactId> 35 <scope>test</scope> 36 </dependency> 37 <!-- druid 驱动 --> 38 <dependency> 39 <groupId>com.alibaba</groupId> 40 <artifactId>druid</artifactId> 41 <version>1.1.9</version> 42 </dependency> 43 <!-- sqlite3驱动包 --> 44 <dependency> 45 <groupId>org.xerial</groupId> 46 <artifactId>sqlite-jdbc</artifactId> 47 <version>${sqlite.jdbc.version}</version> 48 </dependency> 49 </dependencies> 50 51 <build> 52 <plugins> 53 <plugin> 54 <groupId>org.springframework.boot</groupId> 55 <artifactId>spring-boot-maven-plugin</artifactId> 56 <configuration> 57 <fork>true</fork> 58 </configuration> 59 </plugin> 60 <plugin> 61 <groupId>org.apache.maven.plugins</groupId> 62 <artifactId>maven-jar-plugin</artifactId> 63 <configuration> 64 <archive> 65 <manifest> 66 <addClasspath>true</addClasspath> 67 <classpathPrefix></classpathPrefix> 68 <mainClass>com.xuanyin.HomektvApplication</mainClass> 69 </manifest> 70 </archive> 71 </configuration> 72 </plugin> 73 </plugins> 74 </build> 75</project>

3.添加项目的数据库配置文件application.yml

1# Tomcat 2server: 3 tomcat: 4 uri-encoding: UTF-8 5 max-threads: 1000 6 min-spare-threads: 30 7 port: 8088 8#spring 9spring: 10 # 指定静态资源的路径 11 resources: 12 static-locations: classpath:/static/,classpath:/views/,file:${web.upload},file:${web.ueditorUpload} 13 datasource: 14 driver-class-name: org.sqlite.JDBC 15# 方式一: 引用外部文件 16# url: jdbc:sqlite:D:/eclipse/xy.db 17#方式二: 引用项目中的文件 18 url: jdbc:sqlite::resource:static/sqlite/xy.db 19 username: 20 password: 21 22# Mybatis配置 23mybatis: 24 mapperLocations: classpath:mapper/**/*.xml 25 #configLocation: classpath:mybatis.xml 26# sql打印 27logging: 28 level: debug 29 level.com.xuanyin: debug 30 path: logs/ 31# file: admin.log

4.添加测试Controller以及Server和Mapper等

  注意各层级的注解的使用

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

SpringBoot整合Sqlite数据库流程 - HelloWorld