This commit is contained in:
peri 2024-09-29 17:09:01 +08:00
parent 86cafedf57
commit 3e1d32c06f
41 changed files with 844 additions and 6 deletions

View File

@ -7,18 +7,22 @@
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="02-Spring-Dependency-Injection-1" />
<module name="04-Spring-Annotate" />
<module name="SpringMVC-Start" />
<module name="03-Spring-Annotate" />
<module name="Spring-Quick-Start" />
<module name="MyBatis-Quick-Start" />
<module name="SpringBoot-Quick-Start" />
<module name="02-Spring-Dependency-Injection-1" />
<module name="04-Spring-Annotate" />
<module name="SpringBoot-RESTful" />
<module name="Spring-Quick-Start" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="MyBatis-Quick-Start" options="-parameters" />
<module name="SpringBoot-Quick-Start" options="-parameters" />
<module name="SpringBoot-RESTful" options="-parameters" />
</option>
</component>
</project>

17
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="mb202201080229@10.33.66.120" uuid="28d899b4-8395-4b9b-a1bd-ef75e9041f60">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://10.33.66.120:3306/mb202201080229</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -13,5 +13,7 @@
<file url="file://$PROJECT_DIR$/05-SpringMVC-Quick-Start/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/06-Spring-Quick-Start/06-Spring-Quick-Start/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/06-SpringBoot-Quick-Start/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/07-SpringBoot-RESTful/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/08-MyBatis-Quick-Start/src/main/java" charset="UTF-8" />
</component>
</project>

9
.idea/kotlinc.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Kotlin2JsCompilerArguments">
<option name="moduleKind" value="plain" />
</component>
<component name="Kotlin2JvmCompilerArguments">
<option name="jvmTarget" value="1.8" />
</component>
</project>

View File

@ -11,6 +11,8 @@
<option value="$PROJECT_DIR$/05-SpringMVC-Quick-Start/pom.xml" />
<option value="$PROJECT_DIR$/06-Spring-Quick-Start/06-Spring-Quick-Start/pom.xml" />
<option value="$PROJECT_DIR$/06-SpringBoot-Quick-Start/pom.xml" />
<option value="$PROJECT_DIR$/07-SpringBoot-RESTful/pom.xml" />
<option value="$PROJECT_DIR$/08-MyBatis-Quick-Start/pom.xml" />
</list>
</option>
</component>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="teacher" class="edu.leijiaqi.entity.PETeacher"></bean>
<bean name="student" class="edu.leijiaqi.entity.Student">
<!-- <property name="teacher" ref="teacher"></property>-->
<constructor-arg name="teacher" ref="teacher"></constructor-arg>
<constructor-arg name="name" value="leijiaqi"></constructor-arg>
</bean>
</beans>

View File

@ -13,5 +13,13 @@
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.12</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,11 +1,13 @@
package edu.leijiaqi;
import edu.leijiaqi.config.MainConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Main {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(MainConfiguration.class);
Student student =(Student)context.getBean();
Student student =(Student)context.getBean("student");
student.study();
}
}

View File

@ -4,6 +4,8 @@ import edu.leijiaqi.Teacher;
public class MainConfiguration implements Teacher {
private Teacher teacher;
public Student()
public void Student(){
}
}

View File

@ -0,0 +1,56 @@
<?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>
<groupId>edu.leijiaqi</groupId>
<artifactId>SpringMVC-Start</artifactId>
<version>1.0-SNAPSHOT</version>
<name>05-SpringMVC-Quick-Start</name>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>22</maven.compiler.target>
<maven.compiler.source>22</maven.compiler.source>
<junit.version>5.11.0-M2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin> </plugins>
</build>
</project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>springmvc</servlet-name>
<url-pattern>/*</url-pattern>
</servlet>
</web-app>

View File

@ -0,0 +1,12 @@
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %></h1>
<br/>
<a href="hello-servlet">Hello Servlet</a>
</body>
</html>

View File

@ -0,0 +1,33 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--开启包扫描-->
<context:component-scan base-package="edu.leijiaqi.controller"/>
<!--开启注解驱动注册一些必要的Bean到SpringMVC容器里面-->
<mvc:annotation-driven>
<!-- 处理乱码 -->
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 视图解析器
作用1.捕获后端控制器的返回值="index"
2.解析: 在返回值的前后 拼接 ==> "/index.jsp"
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<!-- 后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
</beans>

33
06-SpringBoot-Quick-Start/.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -0,0 +1,84 @@
<?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>3.3.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.leijiaqi</groupId>
<artifactId>SpringBoot-Quick-Start</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>06-SpringBoot-Quick-Start</name>
<description>06-SpringBoot-Quick-Start</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,12 @@
package edu.leijiaqi.springbootquickstart;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,8 @@
spring.application.name=06-SpringBoot-Quick-Start
#?????
spring.devtools.restart.enabled=true
#??????
spring.devtools.restart.additional-paths=src/main/java
#??cLaSSpath????WEB-INF??????????(?????????
spring.devtools.restart.exclude=static/**

View File

@ -0,0 +1,13 @@
package edu.leijiaqi.springbootquickstart;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ApplicationTests {
@Test
void contextLoads() {
}
}

33
07-SpringBoot-RESTful/.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -0,0 +1,78 @@
<?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>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.leijiaqi</groupId>
<artifactId>SpringBoot-RESTful</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>07-SpringBoot-RESTful</name>
<description>07-SpringBoot-RESTful</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package edu.leijiaqi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,57 @@
package edu.leijiaqi.controller;
import edu.leijiaqi.pojo.Student;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
@RestController
public class StudentController {
private static final Map<Integer,Student> students = new HashMap<>();
private static final AtomicInteger counter = new AtomicInteger();
//创建学生
@PostMapping("/student")
public Student insertStudent(@RequestBody Student student) {
Integer id = counter.incrementAndGet();
student.setId(id);
students.put(id,student);
System.out.println(student);
return student;
}
//查询所有学生
@GetMapping("/student")
public Map<Integer,Student> getAllStudents() {
System.out.println(students);
return students;
}
//根据id查询单个学生
@GetMapping("/student/{id}")
public Student getStudent(@PathVariable Integer id) {
System.out.println(students.get(id));
return students.get(id);
}
//根据id删除单个学生
@DeleteMapping("/student/{id}")
public String deleteStudent(@PathVariable Integer id) {
students.remove(id);
System.out.println(students);
return "Remove OK";
}
//根据id更新单个学生
@PutMapping("/student/{id}")
public Student updateStudentById(@PathVariable Integer id,@RequestBody Student student) {
Student oldStudent = students.get(id);
if(oldStudent != null) {
oldStudent.setName(student.getName());
oldStudent.setAge(student.getAge());
}
return oldStudent;
}
}

View File

@ -0,0 +1,16 @@
package edu.leijiaqi.pojo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
//@Getter
//@Setter
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Student {
@JsonIgnore
private Integer id;
private String name;
private Integer age;
}

View File

@ -0,0 +1,8 @@
spring.application.name=07-SpringBoot-RESTful
#?????
spring.devtools.restart.enabled=true
#??????
spring.devtools.restart.additional-paths=src/main/java
#??cLaSSpath????WEB-INF??????????(?????????
spring.devtools.restart.exclude=static/**

View File

@ -0,0 +1,13 @@
package edu.leijiaqi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ApplicationTests {
@Test
void contextLoads() {
}
}

33
08-MyBatis-Quick-Start/.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -0,0 +1,106 @@
<?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>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.leijiaqi</groupId>
<artifactId>MyBatis-Quick-Start</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>08-MyBatis-Quick-Start</name>
<description>08-MyBatis-Quick-Start</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.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>3.0.3</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package edu.leijiaqi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,29 @@
package edu.leijiaqi.mapper;
import edu.leijiaqi.pojo.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface StudentMapper {
//查询全部学生信息
@Select("select * from student")
List<Student> list();
//根据ID查询学生
// @Select("select * from student where id = ${id}")
@Select("select * from student where id = #{id}")
Student getById(String id);
//根据姓氏查询
@Select("select * from student where name like concat(#{lastName},'%')")
List<Student> getByLastName(String lastName);
//查询姓名为n个字的学生
@Select("select * from student where char_length(student.name=#{len})")
List<Student> getByNameLen(int Len);
}

View File

@ -0,0 +1,19 @@
package edu.leijiaqi.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Student {
private String id;
private String name;
private String password;
private Integer gender;
private LocalDateTime createTime;
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,19 @@
spring.application.name=08-MyBatis-Quick-Start
#?????
spring.devtools.restart.enabled=true
#??????
spring.devtools.restart.additional-paths=src/main/java
#??cLaSSpath????WEB-INF??????????(?????????
spring.devtools.restart.exclude=static/*
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#??????jdbc???localhost/??/?????
spring.datasource.url=jdbc:mysql://10.33.66.120:3306/mb202201080229
spring.datasource.username=mb202201080229
spring.datasource.password=WJNZVR129112
#??mybatis????????????
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
#??mybatis???????????
mybatis.configuration.map-underscore-to-camel-case=true

View File

@ -0,0 +1,49 @@
package edu.leijiaqi;
import edu.leijiaqi.mapper.StudentMapper;
import edu.leijiaqi.pojo.Student;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
class ApplicationTests {
//测试的函数
@Autowired
private StudentMapper studentMapper;//实例化自动注入的
@Test
public void testListStudent() {
List<Student> students = studentMapper.list();
for (Student stu : students) {
System.out.println(stu);
}
}
@Test
public void testGetById() {
Student student = studentMapper.getById("12138");
System.out.println(student);
}
@Test
public void testGetByLastName() {
List<Student> students = studentMapper.getByLastName("");
if (students != null) {
System.out.println("有数据" + students);
}else {
System.out.println("不存在");
}
}
@Test
public void testGetByNameLen() {
List<Student> students = studentMapper.getByNameLen(5);
if (students != null) {
System.out.println(students);
}else {
System.out.println("不存在");
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
</web-app>

View File

@ -0,0 +1,12 @@
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>JSP - Hello World</title>
</head>
<body>
<h1><%= "Hello World!" %></h1>
<br/>
<a href="hello-servlet">Hello Servlet</a>
</body>
</html>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>