1.创建项目
方式一: 通过网站https://start.spring.io/
方式二: 通过开发工具(IDEA或者Eclipse自行百度)
2.修改pom.xml配置文件,添加必要的驱动包
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/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>org.mybatis.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>org.xerial</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> <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.添加项目的数据库配置文件application.yml
# 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: classpath:mybatis.xml # sql打印 logging: level: debug level.com.xuanyin: debug path: logs/ # file: admin.log
4.添加测试Controller以及Server和Mapper等
注意各层级的注解的使用
个人学习随笔,若是帮助到您,请给个推荐,或者评论一下下,谢谢了哟。若有不懂之处,请联系QQ:351094262(验证信息:博客园),原创不易,转载请标明出处!