赞
踩
说明:本文是既《SpringBoot+thymeleaf完成视频记忆播放功能》的续写,如有兴趣可点击链接查看。
一、功能背景描述说明:
1、在手机浏览器离开时将看到的视频记录、视频时长和音频的收听记录、收听时长存入数据库记录;
2、用户通过将观看、收听记录导出,能够看到是谁看了哪些视频、看了多长时间、上一次看到的位置等。
二、实现过程:
1)框架:SpringBoot+thymeleaf
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 https://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.6.4</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <groupId>com.example</groupId>
- <artifactId>mybatisdemo02</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <name>mybatisdemo02</name>
- <description>Demo project for Spring Boot</description>
- <properties>
- <java.version>17</java.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- <version>3.5.2</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>8.0.15</version>
- </dependency>
-
- <!-- video player 读取视频播放时长-->
- <!--<dependency>
- <groupId>it.sauronsoftware</groupId>
- <artifactId>jave</artifactId>
- <version>1.0.2</version>
- </dependency>-->
-
- <!--视频多媒体工具包 包含 FFmpeg、OpenCV-->
- <dependency>
- <groupId>org.bytedeco</groupId>
- <artifactId>javacv-platform</artifactId>
- <version>1.5.3</version>
- </dependency>
- <!-- 音频依赖 -->
- <dependency>
- <groupId>ws.schild</groupId>
- <artifactId>jave-core</artifactId>
- <version>2.4.6</version>
- </dependency>
- <!--<dependency>
- <groupId>ws.schild</groupId>
- <artifactId>jave-nativebin-win32</artifactId>
- <version>3.1.1</version>
- </dependency>-->
- <dependency>
- <groupId>ws.schild</groupId>
- <artifactId>jave-native-win64</artifactId>
- <version>2.4.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.webjars.bower</groupId>
- <artifactId>jquery</artifactId>
- <version>1.9.1</version>
- </dependency>
-
-
- <!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.openjfx</groupId>
- <artifactId>javafx-controls</artifactId>
- <version>16</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>2.0.21</version>
- </dependency>
- <!-- 页面 -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-thymeleaf</artifactId>
- </dependency>
- <!-- excle工具 -->
- <dependency>
- <groupId>org.apache.poi</groupId>
- <artifactId>poi-ooxml</artifactId>
- <version>4.1.2</version>
- </dependency>
- <!-- 时间日期工具 -->
- <dependency>
- <groupId>cn.hutool</groupId>
- <artifactId>hutool-core</artifactId>
- <version>5.8.14</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- <exclusions>
- <!-- 排除自带的logback依赖 -->
- <exclusion>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-log4j</artifactId>
- <version>1.3.8.RELEASE</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- <!-- 指向静态资源路径 -->
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.properties</include>
- <include>**/*.xml</include>
- </includes>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
-
- </project>
3)配置application.properties属性文件
- server.port=8080
- spring.application.name=mybatisdemo02
- spring.thymeleaf.prefix=classpath:/templates/
- spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/
- #pring.resources.static-locations=classpath:/static/
- spring.thymeleaf.suffix=.html
- spring.thymeleaf.mode=HTML5
- # mybatis日志打印
- mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
- log4j.logger.org.mybatis.caches=DEBUG
4)配置log4j.properties属性文件
- log4j.logger.org.springframework.boot.autoconfigure=ERROR
- #log4j 配置
- #log4j定义了8个级别的log优先级从高到低依次为:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL。
- #CONSOLE前面的DEBUG是控制台需要打印什么DEBUG级别以上的日志的信息
- log4j.rootLogger=DEBUG, CONSOLE, ERROR, WARN, INFO, DEBUG, ALL
- #-----------------------------------------------------------------------------------------------------
- #输出信息到控制台CONSOLE
- log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
- log4j.appender.CONSOLE.Target = System.out
- log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
- log4j.appender.CONSOLE.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
- #-----------------------------------------------------------------------------------------------------
- #输出ERROR 级别以上的日志到error.log
- log4j.logger.ERROR=ERROR
- log4j.appender.ERROR = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.ERROR.File =E:/log/error.log
- log4j.appender.ERROR.Threshold = ERROR
- log4j.appender.ERROR.Append = true
- log4j.appender.ERROR.layout = org.apache.log4j.PatternLayout
- log4j.appender.ERROR.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
- #-----------------------------------------------------------------------------------------------------
- #输出DEBUG 级别以上的日志到debugger.log
- log4j.logger.org.apache.ibatis.cache.Cache=DEBUG
- log4j.appender.DEBUG = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.DEBUG.File = E:/log/debugger.log
- log4j.appender.DEBUG.Threshold = DEBUG
- log4j.appender.DEBUG.Append = true
- log4j.appender.DEBUG.layout = org.apache.log4j.PatternLayout
- log4j.appender.DEBUG.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
- #-----------------------------------------------------------------------------------------------------
- #输出ALL级别的日志到all.log
- log4j.logger.ALL=ALL
- log4j.appender.ALL = org.apache.log4j.DailyRollingFileAppender
- log4j.appender.ALL.File = E:/log/all.log
- log4j.appender.file.DatePattern ='.'yyyy-MM-dd
- log4j.appender.ALL.Threshold = ALL
- log4j.appender.ALL.Append = true
- log4j.appender.ALL.layout = org.apache.log4j.PatternLayout
- log4j.appender.ALL.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
-
-
5)配置mybatisConfig.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE configuration
- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-config.dtd">
- <configuration>
- <settings>
- <setting name="lazyLoadingEnabled" value="false" />
- <setting name="logImpl" value="STDOUT_LOGGING" />
- <!--二级缓存:全局地开启或关闭配置文件中的所有映射器已经配置的任何缓存。 -->
- <setting name="cacheEnabled" value="true"/>
- </settings>
-
- <typeAliases>
- <typeAlias type="com.example.mybatisdemo02.model.Person" alias="Person"/>
- <typeAlias type="com.example.mybatisdemo02.model.Warn" alias="Warn"/>
- </typeAliases>
-
- <!-- environments表示配置Mybatis的开发环境,可以配置多个环境,在众多具体环境中,使用default属性指定实际运行时使用的环境。default属性的取值是environment标签的id属性的值。 -->
- <environments default="development">
- <!-- environment表示配置Mybatis的一个具体的环境 -->
- <environment id="development">
- <!-- Mybatis的内置的事务管理器 -->
- <transactionManager type="JDBC"/>
- <!-- 配置数据源 -->
- <dataSource type="POOLED">
- <!-- 建立数据库连接的具体信息 -->
- <property name="driver" value="com.mysql.cj.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false" />
- <property name="username" value="root"/>
- <property name="password" value="xxxxxx"/>
- </dataSource>
- </environment>
- </environments>
-
- <mappers>
- <!--引入映射文件-->
- <package name="com.example.mybatisdemo02.dao"></package>
- <!--<mapper resource="com/example/mybatisdemo/dao/PersonMapper.xml"
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。