--- title: 毕业设计(2) tags: - java - ssm - react - ant design - typescript categories: 毕业设计 date: 2022-12-07 12:36:32 summary: 数据库配置何整合ssm框架 --- ## 四、数据库创建 ```sql use workingsystem; -- #行政班级表 create table adminClass ( id int primary key not null auto_increment comment '行政班级id', name varchar(255) not null comment '班级名称', teacher_id int not null default 0 comment '所属教师id' ); -- #教学班级表 create table teacherClass ( id int primary key not null auto_increment comment '行政班级id', name varchar(255) not null comment '班级名称', teacher_id int not null default 0 comment '所属教师id' ); -- #学生表 create table student ( id int primary key not null auto_increment comment '学生id', name varchar(255) not null default '' comment '学生姓名', card_id long not null comment '学生卡id', phone varchar(15) not null default 0 comment '手机号', password varchar(255) not null comment '账号密码', admin_class_id int default 0 not null comment '所属行政班级id', teacher_class_id int default 0 not null comment '所属教学班级id' ); -- #教师表 create table teacher ( id int primary key not null auto_increment comment '教师id', card_id long not null comment '教师工号', name varchar(255) not null default '' comment '教师姓名', phone varchar(15) not null default 0 comment '手机号', password varchar(255) not null comment '账号密码' ); -- #家长表 create table patriarch ( id int primary key not null auto_increment comment '家长id', name varchar(255) not null default '' comment '家长姓名', phone varchar(15) not null comment '手机号', password varchar(255) not null comment '账号密码', student_id int not null comment '对应绑定的学生id' ); create table work_record ( id int primary key not null auto_increment comment '作业记录id', work_id int not null default 0 comment '作业id', student_id int not null default 0 comment '提交的学生id', submit_time datetime not null comment '提交时间', end_time datetime comment '截至时间', appendix varchar(255) comment '附件地址', teacher_id int default 0 not null comment '创建的教师的id' ); create table work ( id int primary key not null auto_increment comment '作业id', name varchar(255) not null comment '作业名称', description longtext comment '作业描述', create_time datetime comment '创建时间', end_time datetime comment '截至时间', appendix varchar(255) comment '附件地址', teacher_id int comment '创建教师的id', admin_class_id int default 0 comment '行政班级id', teacher_class_id int default 0 comment '教学班级的id' ); ``` ## 五、SSM框架整合 ### 1. 项目创建 项目才有idea进行开发,首先在idea中创建maven项目 ![](https://s2.loli.net/2022/12/07/vBe9562q4XfJZQY.png) ### 2. 依赖添加 pom.xml ```xml 4.0.0 org.gjs WorkingSystem war v1.0.0 WorkingSystem Maven Webapp https://maven.apache.org 11 11 11 5.3.20 8.0.28 2.0.3 2.19.0 2.14.0 junit junit 4.13.2 test org.springframework spring-context ${spring-version} org.springframework spring-core ${spring-version} org.springframework spring-web ${spring-version} org.springframework spring-beans ${spring-version} org.springframework spring-webmvc ${spring-version} org.springframework.session spring-session-core 2.6.2 org.springframework spring-aop ${spring-version} org.springframework spring-jdbc ${spring-version} org.springframework spring-test ${spring-version} mysql mysql-connector-java ${mysql-version} org.mybatis mybatis 3.5.9 org.mybatis mybatis-spring 2.0.7 com.alibaba druid 1.2.9 com.fasterxml.jackson.core jackson-databind ${jackson.version} com.fasterxml.jackson.core jackson-core ${jackson.version} com.fasterxml.jackson.core jackson-annotations ${jackson.version} org.slf4j slf4j-log4j12 ${slf4j.version} org.slf4j slf4j-api ${slf4j.version} org.apache.logging.log4j log4j-core ${log4j.version} org.springframework.data spring-data-commons 2.7.1 javax.servlet javax.servlet-api 4.0.1 provided org.aspectj aspectjweaver 1.9.9.1 com.auth0 java-jwt 4.2.1 org.jetbrains annotations-java5 RELEASE compile WorkingSystem maven-compiler-plugin 3.10.1 11 11 org.apache.maven.plugins maven-compiler-plugin 7 7 ``` ### 3. 配置web.xml文件 web.xml ```xml Archetype Created Web Application log4jConfigLocation classpath:log4j.properties org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:spring/spring.xml CharacterEncodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding utf-8 CharacterEncodingFilter /* mvc org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:spring/spring-mvc.xml 1 mvc / ``` ### 4. 配置日志输出 log4j.properties ```properties log4j.rootLogger = debug, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{MM-dd HH:mm:ss} [%X{traceId}] %-5p [%t] %c{2}:%L - %m%n ``` ### 5. spring配置文件 spring.xml ```xml ``` ### 6. spring-mvc配置 spring-mvc.xml ```xml ``` ### 7.mybatis整合 dao.xml ```xml ```