SpringBoot整合Sqlite数据库流程1.创建项⽬
⽅式⼀:通过⽹站start.spring.io/
⽅式⼆:通过开发⼯具(IDEA或者Eclipse⾃⾏百度)
2.修改l配置⽂件,添加必要的驱动包
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0" xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/><!-- lookup parent from repository -->
</parent>
<groupId>com.xuanyin</groupId>
<artifactId>homektv</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- 统⼀管理jar包版本 -->
<properties>
<java.version>12</java.version>
<mybatis.spring.boot.version>2.0.0</mybatis.spring.boot.version>
<sqlite.jdbc.version>3.27.2.1</sqlite.jdbc.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId&batis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- druid 驱动 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.9</version>
</dependency>
<!-- sqlite3驱动包 -->
<dependency>
<groupId&ial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite.jdbc.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
springframework jar包下载<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix></classpathPrefix>
<mainClass>com.xuanyin.HomektvApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.添加项⽬的数据库配置⽂件l
# Tomcat
server:
tomcat:
uri-encoding: UTF-8
max-threads: 1000
min-spare-threads: 30
port: 8088
#spring
spring:
# 指定静态资源的路径
resources:
static-locations: classpath:/static/,classpath:/views/,file:${web.upload},file:${web.ueditorUpload} datasource:
driver-class-name: org.sqlite.JDBC
# ⽅式⼀:引⽤外部⽂件
# url: jdbc:sqlite:D:/eclipse/xy.db
#⽅式⼆:引⽤项⽬中的⽂件
url: jdbc:sqlite::resource:static/sqlite/xy.db
username:
password:
# Mybatis配置
mybatis:
mapperLocations: classpath:mapper/**/*.xml
#configLocation: l
# sql打印
logging:
level: debug
level.xuanyin: debug
path: logs/
# file: admin.log
4.添加测试Controller以及Server和Mapper等
注意各层级的注解的使⽤
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论