springboot-简单的学⽣选课系统(含mybatis部署和使⽤)-1
环境
win10 + eclipse + java1.8 + mysql + edge
效果
⽀持:
1. 添加学⽣
2. 添加课程(需要提供课程名称、上课⽇期和开始时间)
3. 注册课程(需要提供学⽣的id和课程的id,并且检测是否撞课,即只有学⽣当时没有课程才能注册)
4. 查询选上某个课程的学⽣列表
5. 查询某个学⽣的所选课程
6. 查询某个学⽣周⼏的课程安排
由于本⽂只⽤来梳理springboot、mybatis以及mysql的简单使⽤⽅法,所以我尽可能地简化了功能,因此再加⼀个设定:对于所有课程,每节课都是1⼩时的,⽽且不限制数量。
实现的效果⼤概如图所⽰:
另外还有个给⽤户结果的页⾯:
数据库设计
create database demo;
use demo;
create table student(
id int(11) not null auto_increment, name varchar(255),
primary key(id)
);
create table course(
id int(11) not null auto_increment, name varchar(255),
weekday int(3) not null,
start int(3) not null,
primary key(id)
);
create table enroll(
id int(11) not null auto_increment, sid int(11),
cid int(11),
primary key(id)
);
项⽬结构
适合新手的spring bootserver:
port: 3000
error:
whitelabel:
enabled: false
spring:
datasource:
username: ⽤户名
password: 密码
url: jdbc:mysql://localhost:3306/数据库名称?characterEncoding=UTF-8
thymeleaf:
mode: HTML
encoding: UTF-8
cache: false
servlet:
content-type: text/html
servlet:
multipart:
max-file-size: 128MB
max-request-size: 128MB
⽹页的模板引擎我选的是thymeleaf。它的备忘录在:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="/POM/4.0.0"xsi="/2001/XMLSchema-instance"
schemaLocation="/POM/4.0.0 /xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId&le</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
&porting.outputEncoding>UTF-8</porting.outputEncoding>
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<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>2.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<artifactId>mssql-jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId&ator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.7.RELEASE</version>
<configuration>
<mainClass&le.demo.DemoApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论