diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 64364ac..e0d29de 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -7,18 +7,22 @@ - - - + + + + + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml new file mode 100644 index 0000000..fe02b13 --- /dev/null +++ b/.idea/dataSources.xml @@ -0,0 +1,17 @@ + + + + + mysql.8 + true + com.mysql.cj.jdbc.Driver + jdbc:mysql://10.33.66.120:3306/mb202201080229 + + + + + + $ProjectFileDir$ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 69b0f96..2217f56 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -13,5 +13,7 @@ + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..ee74011 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 79346cf..44ac6ac 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,6 +11,8 @@ diff --git a/02-Spring-Dependency-Injection-1/target/classes/application.xml b/02-Spring-Dependency-Injection-1/target/classes/application.xml new file mode 100644 index 0000000..15fd616 --- /dev/null +++ b/02-Spring-Dependency-Injection-1/target/classes/application.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/Main.class b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/Main.class new file mode 100644 index 0000000..5a5547d Binary files /dev/null and b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/Main.class differ diff --git a/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/ArtTeacher.class b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/ArtTeacher.class new file mode 100644 index 0000000..3f6f05b Binary files /dev/null and b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/ArtTeacher.class differ diff --git a/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/PETeacher.class b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/PETeacher.class new file mode 100644 index 0000000..c4b0288 Binary files /dev/null and b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/PETeacher.class differ diff --git a/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Student.class b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Student.class new file mode 100644 index 0000000..c6662e1 Binary files /dev/null and b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Student.class differ diff --git a/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Teacher.class b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Teacher.class new file mode 100644 index 0000000..c60b1a7 Binary files /dev/null and b/02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Teacher.class differ diff --git a/03-Spring-Annotate/pom.xml b/03-Spring-Annotate/pom.xml index 54a057d..837accf 100644 --- a/03-Spring-Annotate/pom.xml +++ b/03-Spring-Annotate/pom.xml @@ -13,5 +13,13 @@ 22 UTF-8 + + + org.springframework + spring-context + 6.1.12 + compile + + \ No newline at end of file diff --git a/03-Spring-Annotate/src/main/java/edu/leijiaqi/Main.java b/03-Spring-Annotate/src/main/java/edu/leijiaqi/Main.java index 6fe18b5..c269249 100644 --- a/03-Spring-Annotate/src/main/java/edu/leijiaqi/Main.java +++ b/03-Spring-Annotate/src/main/java/edu/leijiaqi/Main.java @@ -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(); } } diff --git a/03-Spring-Annotate/src/main/java/edu/leijiaqi/config/MainConfiguration.java b/03-Spring-Annotate/src/main/java/edu/leijiaqi/config/MainConfiguration.java index bc2c27c..173ce94 100644 --- a/03-Spring-Annotate/src/main/java/edu/leijiaqi/config/MainConfiguration.java +++ b/03-Spring-Annotate/src/main/java/edu/leijiaqi/config/MainConfiguration.java @@ -4,6 +4,8 @@ import edu.leijiaqi.Teacher; public class MainConfiguration implements Teacher { private Teacher teacher; - public Student() + public void Student(){ + + } } diff --git a/05-SpringMVC-Quick-Start/pom.xml b/05-SpringMVC-Quick-Start/pom.xml new file mode 100644 index 0000000..bd686fa --- /dev/null +++ b/05-SpringMVC-Quick-Start/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + edu.leijiaqi + SpringMVC-Start + 1.0-SNAPSHOT + 05-SpringMVC-Quick-Start + war + + + UTF-8 + 22 + 22 + 5.11.0-M2 + + + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + provided + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + org.springframework + spring-webmvc + 6.1.6 + + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + + \ No newline at end of file diff --git a/05-SpringMVC-Quick-Start/src/main/webapp/WEB-INF/web.xml b/05-SpringMVC-Quick-Start/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..9160f7d --- /dev/null +++ b/05-SpringMVC-Quick-Start/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,20 @@ + + + + springmvc + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + classpath:springmvc.xml + + 1 + + + + springmvc + /* + + \ No newline at end of file diff --git a/05-SpringMVC-Quick-Start/src/main/webapp/index.jsp b/05-SpringMVC-Quick-Start/src/main/webapp/index.jsp new file mode 100644 index 0000000..3d6d7b9 --- /dev/null +++ b/05-SpringMVC-Quick-Start/src/main/webapp/index.jsp @@ -0,0 +1,12 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + JSP - Hello World + + +

<%= "Hello World!" %>

+
+Hello Servlet + + \ No newline at end of file diff --git a/05-SpringMVC-Quick-Start/target/classes/edu/leijiaqi/controller/IndexController.class b/05-SpringMVC-Quick-Start/target/classes/edu/leijiaqi/controller/IndexController.class new file mode 100644 index 0000000..1d5d214 Binary files /dev/null and b/05-SpringMVC-Quick-Start/target/classes/edu/leijiaqi/controller/IndexController.class differ diff --git a/05-SpringMVC-Quick-Start/target/classes/springmvc.xml b/05-SpringMVC-Quick-Start/target/classes/springmvc.xml new file mode 100644 index 0000000..c31cc50 --- /dev/null +++ b/05-SpringMVC-Quick-Start/target/classes/springmvc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/06-SpringBoot-Quick-Start/.gitignore b/06-SpringBoot-Quick-Start/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/06-SpringBoot-Quick-Start/.gitignore @@ -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/ diff --git a/06-SpringBoot-Quick-Start/pom.xml b/06-SpringBoot-Quick-Start/pom.xml new file mode 100644 index 0000000..e40c2c1 --- /dev/null +++ b/06-SpringBoot-Quick-Start/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.3 + + + edu.leijiaqi + SpringBoot-Quick-Start + 0.0.1-SNAPSHOT + 06-SpringBoot-Quick-Start + 06-SpringBoot-Quick-Start + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-devtools + true + + + org.projectlombok + lombok + provided + + + + + + + + org.graalvm.buildtools + native-maven-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + + diff --git a/06-SpringBoot-Quick-Start/src/main/java/edu/leijiaqi/springbootquickstart/Application.java b/06-SpringBoot-Quick-Start/src/main/java/edu/leijiaqi/springbootquickstart/Application.java new file mode 100644 index 0000000..a0dfe94 --- /dev/null +++ b/06-SpringBoot-Quick-Start/src/main/java/edu/leijiaqi/springbootquickstart/Application.java @@ -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); + } + +} diff --git a/06-SpringBoot-Quick-Start/src/main/resources/application.properties b/06-SpringBoot-Quick-Start/src/main/resources/application.properties new file mode 100644 index 0000000..860e330 --- /dev/null +++ b/06-SpringBoot-Quick-Start/src/main/resources/application.properties @@ -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/** diff --git a/06-SpringBoot-Quick-Start/src/test/java/edu/leijiaqi/springbootquickstart/ApplicationTests.java b/06-SpringBoot-Quick-Start/src/test/java/edu/leijiaqi/springbootquickstart/ApplicationTests.java new file mode 100644 index 0000000..7b0b8d3 --- /dev/null +++ b/06-SpringBoot-Quick-Start/src/test/java/edu/leijiaqi/springbootquickstart/ApplicationTests.java @@ -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() { + } + +} diff --git a/07-SpringBoot-RESTful/.gitignore b/07-SpringBoot-RESTful/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/07-SpringBoot-RESTful/.gitignore @@ -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/ diff --git a/07-SpringBoot-RESTful/pom.xml b/07-SpringBoot-RESTful/pom.xml new file mode 100644 index 0000000..5259286 --- /dev/null +++ b/07-SpringBoot-RESTful/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.4 + + + edu.leijiaqi + SpringBoot-RESTful + 0.0.1-SNAPSHOT + 07-SpringBoot-RESTful + 07-SpringBoot-RESTful + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + + org.springframework.boot + spring-boot-devtools + true + + + + + + + + org.graalvm.buildtools + native-maven-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/Application.java b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/Application.java new file mode 100644 index 0000000..6d7c4f9 --- /dev/null +++ b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/Application.java @@ -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); + } + +} diff --git a/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/controller/StudentController.java b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/controller/StudentController.java new file mode 100644 index 0000000..eb796c5 --- /dev/null +++ b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/controller/StudentController.java @@ -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 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 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; + } +} diff --git a/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/pojo/Student.java b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/pojo/Student.java new file mode 100644 index 0000000..70bc263 --- /dev/null +++ b/07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/pojo/Student.java @@ -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; +} diff --git a/07-SpringBoot-RESTful/src/main/resources/application.properties b/07-SpringBoot-RESTful/src/main/resources/application.properties new file mode 100644 index 0000000..9aa11b4 --- /dev/null +++ b/07-SpringBoot-RESTful/src/main/resources/application.properties @@ -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/** \ No newline at end of file diff --git a/07-SpringBoot-RESTful/src/test/java/edu/leijiaqi/ApplicationTests.java b/07-SpringBoot-RESTful/src/test/java/edu/leijiaqi/ApplicationTests.java new file mode 100644 index 0000000..d14b418 --- /dev/null +++ b/07-SpringBoot-RESTful/src/test/java/edu/leijiaqi/ApplicationTests.java @@ -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() { + } + +} diff --git a/08-MyBatis-Quick-Start/.gitignore b/08-MyBatis-Quick-Start/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/08-MyBatis-Quick-Start/.gitignore @@ -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/ diff --git a/08-MyBatis-Quick-Start/pom.xml b/08-MyBatis-Quick-Start/pom.xml new file mode 100644 index 0000000..94fa367 --- /dev/null +++ b/08-MyBatis-Quick-Start/pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.4 + + + edu.leijiaqi + MyBatis-Quick-Start + 0.0.1-SNAPSHOT + 08-MyBatis-Quick-Start + 08-MyBatis-Quick-Start + + + + + + + + + + + + + + + 17 + + + + org.springframework.boot + spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.3 + + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + 3.0.3 + test + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.3 + + + + com.mysql + mysql-connector-j + runtime + + + + org.springframework.boot + spring-boot-devtools + true + + + + + + + + org.graalvm.buildtools + native-maven-plugin + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + + + diff --git a/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/Application.java b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/Application.java new file mode 100644 index 0000000..6d7c4f9 --- /dev/null +++ b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/Application.java @@ -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); + } + +} diff --git a/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/mapper/StudentMapper.java b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/mapper/StudentMapper.java new file mode 100644 index 0000000..2562603 --- /dev/null +++ b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/mapper/StudentMapper.java @@ -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 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 getByLastName(String lastName); + + //查询姓名为n个字的学生 + @Select("select * from student where char_length(student.name=#{len})") + List getByNameLen(int Len); +} diff --git a/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/pojo/Student.java b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/pojo/Student.java new file mode 100644 index 0000000..4fde68b --- /dev/null +++ b/08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/pojo/Student.java @@ -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; +} diff --git a/08-MyBatis-Quick-Start/src/main/resources/application.properties b/08-MyBatis-Quick-Start/src/main/resources/application.properties new file mode 100644 index 0000000..bd315ab --- /dev/null +++ b/08-MyBatis-Quick-Start/src/main/resources/application.properties @@ -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 diff --git a/08-MyBatis-Quick-Start/src/test/java/edu/leijiaqi/ApplicationTests.java b/08-MyBatis-Quick-Start/src/test/java/edu/leijiaqi/ApplicationTests.java new file mode 100644 index 0000000..fdb460c --- /dev/null +++ b/08-MyBatis-Quick-Start/src/test/java/edu/leijiaqi/ApplicationTests.java @@ -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 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 students = studentMapper.getByLastName("胡"); + if (students != null) { + System.out.println("有数据" + students); + }else { + System.out.println("不存在"); + } + } + + @Test + public void testGetByNameLen() { + List students = studentMapper.getByNameLen(5); + if (students != null) { + System.out.println(students); + }else { + System.out.println("不存在"); + } + } +} diff --git a/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/WEB-INF/web.xml b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/WEB-INF/web.xml new file mode 100644 index 0000000..0bf2fcb --- /dev/null +++ b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/index.jsp b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/index.jsp new file mode 100644 index 0000000..3d6d7b9 --- /dev/null +++ b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/index.jsp @@ -0,0 +1,12 @@ +<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> + + + + JSP - Hello World + + +

<%= "Hello World!" %>

+
+Hello Servlet + + \ No newline at end of file diff --git a/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/web/WEB-INF/web.xml b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/web/WEB-INF/web.xml new file mode 100644 index 0000000..d80081d --- /dev/null +++ b/out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/web/WEB-INF/web.xml @@ -0,0 +1,6 @@ + + + \ No newline at end of file