From 3e1d32c06f697d44377b0d68385beb903b944bdc Mon Sep 17 00:00:00 2001 From: peri <2698953178@qq.com> Date: Sun, 29 Sep 2024 17:09:01 +0800 Subject: [PATCH] database --- .idea/compiler.xml | 10 +- .idea/dataSources.xml | 17 +++ .idea/encodings.xml | 2 + .idea/kotlinc.xml | 9 ++ .idea/misc.xml | 2 + .../target/classes/application.xml | 11 ++ .../target/classes/edu/leijiaqi/Main.class | Bin 0 -> 978 bytes .../edu/leijiaqi/entity/ArtTeacher.class | Bin 0 -> 545 bytes .../edu/leijiaqi/entity/PETeacher.class | Bin 0 -> 577 bytes .../classes/edu/leijiaqi/entity/Student.class | Bin 0 -> 2445 bytes .../classes/edu/leijiaqi/entity/Teacher.class | Bin 0 -> 137 bytes 03-Spring-Annotate/pom.xml | 8 ++ .../src/main/java/edu/leijiaqi/Main.java | 6 +- .../leijiaqi/config/MainConfiguration.java | 4 +- 05-SpringMVC-Quick-Start/pom.xml | 56 +++++++++ .../src/main/webapp/WEB-INF/web.xml | 20 ++++ .../src/main/webapp/index.jsp | 12 ++ .../leijiaqi/controller/IndexController.class | Bin 0 -> 843 bytes .../target/classes/springmvc.xml | 33 ++++++ 06-SpringBoot-Quick-Start/.gitignore | 33 ++++++ 06-SpringBoot-Quick-Start/pom.xml | 84 ++++++++++++++ .../springbootquickstart/Application.java | 12 ++ .../src/main/resources/application.properties | 8 ++ .../ApplicationTests.java | 13 +++ 07-SpringBoot-RESTful/.gitignore | 33 ++++++ 07-SpringBoot-RESTful/pom.xml | 78 +++++++++++++ .../main/java/edu/leijiaqi/Application.java | 13 +++ .../controller/StudentController.java | 57 ++++++++++ .../main/java/edu/leijiaqi/pojo/Student.java | 16 +++ .../src/main/resources/application.properties | 8 ++ .../java/edu/leijiaqi/ApplicationTests.java | 13 +++ 08-MyBatis-Quick-Start/.gitignore | 33 ++++++ 08-MyBatis-Quick-Start/pom.xml | 106 ++++++++++++++++++ .../main/java/edu/leijiaqi/Application.java | 13 +++ .../edu/leijiaqi/mapper/StudentMapper.java | 29 +++++ .../main/java/edu/leijiaqi/pojo/Student.java | 19 ++++ .../src/main/resources/application.properties | 19 ++++ .../java/edu/leijiaqi/ApplicationTests.java | 49 ++++++++ .../WEB-INF/web.xml | 6 + .../index.jsp | 12 ++ .../web/WEB-INF/web.xml | 6 + 41 files changed, 844 insertions(+), 6 deletions(-) create mode 100644 .idea/dataSources.xml create mode 100644 .idea/kotlinc.xml create mode 100644 02-Spring-Dependency-Injection-1/target/classes/application.xml create mode 100644 02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/Main.class create mode 100644 02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/ArtTeacher.class create mode 100644 02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/PETeacher.class create mode 100644 02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Student.class create mode 100644 02-Spring-Dependency-Injection-1/target/classes/edu/leijiaqi/entity/Teacher.class create mode 100644 05-SpringMVC-Quick-Start/pom.xml create mode 100644 05-SpringMVC-Quick-Start/src/main/webapp/WEB-INF/web.xml create mode 100644 05-SpringMVC-Quick-Start/src/main/webapp/index.jsp create mode 100644 05-SpringMVC-Quick-Start/target/classes/edu/leijiaqi/controller/IndexController.class create mode 100644 05-SpringMVC-Quick-Start/target/classes/springmvc.xml create mode 100644 06-SpringBoot-Quick-Start/.gitignore create mode 100644 06-SpringBoot-Quick-Start/pom.xml create mode 100644 06-SpringBoot-Quick-Start/src/main/java/edu/leijiaqi/springbootquickstart/Application.java create mode 100644 06-SpringBoot-Quick-Start/src/main/resources/application.properties create mode 100644 06-SpringBoot-Quick-Start/src/test/java/edu/leijiaqi/springbootquickstart/ApplicationTests.java create mode 100644 07-SpringBoot-RESTful/.gitignore create mode 100644 07-SpringBoot-RESTful/pom.xml create mode 100644 07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/Application.java create mode 100644 07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/controller/StudentController.java create mode 100644 07-SpringBoot-RESTful/src/main/java/edu/leijiaqi/pojo/Student.java create mode 100644 07-SpringBoot-RESTful/src/main/resources/application.properties create mode 100644 07-SpringBoot-RESTful/src/test/java/edu/leijiaqi/ApplicationTests.java create mode 100644 08-MyBatis-Quick-Start/.gitignore create mode 100644 08-MyBatis-Quick-Start/pom.xml create mode 100644 08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/Application.java create mode 100644 08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/mapper/StudentMapper.java create mode 100644 08-MyBatis-Quick-Start/src/main/java/edu/leijiaqi/pojo/Student.java create mode 100644 08-MyBatis-Quick-Start/src/main/resources/application.properties create mode 100644 08-MyBatis-Quick-Start/src/test/java/edu/leijiaqi/ApplicationTests.java create mode 100644 out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/WEB-INF/web.xml create mode 100644 out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/index.jsp create mode 100644 out/artifacts/05_SpringMVC_Quick_Start_Web_exploded/web/WEB-INF/web.xml 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 0000000000000000000000000000000000000000..5a5547d620275c4aa301428771f945f4cca92979 GIT binary patch literal 978 zcmb7CU2hUW6g|V&!m=$b6|B~3TeU)4+4}u}npl!PZM6x8XnY!Aq=Wl`yMvaWr4Kf0 zVtn>T8SgAaO4^vXo6Kb9-nr-8bMCL--+lmif=4D2NE%34NF&3r(B~hx?Q*|ozi9VG zM=@j`OJAy|49QBhWgyG27lb`K8idmCy$!i1J_g}CyA$|I94k8-4hBJ}?1syu=#Zs+l|_NUh}5tve3i!{ ziUyV}TtJDT_Agdv8Bm>`P`^7qmv8d8ny=9rO* zGA>!Ttd&e_mZKc5VAa4?3)iqVBX4sQDdCZ-!H`5QjnQOaA5yD|8W!BEo7lj012-(( z#3sX1tjKH*wV{nrF10bE*@UyUtirH3!}@?rN>4R{t{@j2>5Jz>uPwrtyzSCW(Fr=- zZShd*^W-w6j$}j}oHLc`RLYAhmMd>gsrJ`3iu16iADG5;Nc%3I`pOh literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..3f6f05b475162d6d52896b8f660375e4214ef589 GIT binary patch literal 545 zcmaKpyGjE=6o&uFZIif~m>BO@ut+T2(jqE|U=>t|q@Tn=Cv0|gGZE~xvk*a0P_Xa~ zf)*;?9>C|&Xy+S1yZoc2_44k00+&pAT;6MiEE5frN=9IvA3F&=`z0&9)tq zOMmD!A5LP@S;=M!209rA#d6KEg)B?HE-m3GsWz<{Pb~>vS`{8cVAfq046&Sa#C)w% z6y6dq+LTG;+!D77+><)~Oa|1dtTGJe{>Nq+f=VkeMDuRVD~UO&nXzx>as4NZAVnL{ z#|N50h-?={7I{WKICcqk)+~3E)n&ks9^k9W?%vCFR-!{Cq97unQ|g2Q z5s%*IK(_M@#GECIWSg1H%zu6}Cv#pt@1FonVJMCoge-(@L=Yu3<;A9OT;Z)a3)#HP zX+m^Tc}h&D;E4}3`&MrxjTa|%@PC`#L$&Y{#p7EC@ zp)sXAIbSSfWw0c&E@u)cKPTLb2$YF`l3~57HV6Z$YRt;mBq5^B284LpF9ta|rwp>8 zq8K+X#t_>0K7=txYE_bsvWgvtew)VFGz3AhJ&|hhuD8qo* cHLOJa4H|y|=07l%&m8>&iB%v2T&=<27uFGr=l}o! literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c6662e1d4d819bff600bcf71f97821fbfa4bd783 GIT binary patch literal 2445 zcmb7FT~ixX7=BK&n@z$JLM+e}+JaKe2Q;--Z4;>42tox~8>FM&xP%?D5O!&H(;5DW z;}4JWsg^pW&qypR>D=P$Dx4j1vJkz>J76caCxa0a5Y%2^dXLfhNO-@ z=>Op~#0sdsQ-NqMzm`M_0~*pg2Ia=|mhsdmH4S^S^k99(3-bE}m}U)3=#qr^-Z!j-;W*YO4>Ng92v_!(ZHqaHb?@TQKpkYkPw!);WZ4OT-o z7Bg&7K}Qi&0wX)dwpn%Ty5T*xJc4Z3Gi=WlsOHYi?rg*!Nw5npo4iLdgYW}OmTj)I zch=3;s2>NxbIoX3avmBLuVFET-f9SCQxUlNzf)Xe58SREjGylzPrOEa!1Jm8 zhEk9S;ha`U*m@T4c)qH2S;A1yA= zG2kK<(K6k3lgf>E9I2DRzPRTE>9N|H({9zxc}sGwhtyq{YT+@s=Qy70wT#_m(`z^z z?m!IpllT-%8kVI#Rs<$H!m{kA&bG-@E6+e6nR%n`IW4yLn{Mfcz`*H(VQ(}|cXG*b zw%favv$E;3oZ7g$w`=x*f7OLQK4V>`&_&f~Hfxq=R^oUla4D=i7q(zlOpQyXW<{Q) zEZVl&sx}SRHC+ugfoo@K?p2D0&jqfW4`rKzx-r3%o8q~P@W&g`AMuvqI|+el=zL!1 z>^9#*S_?ly{0vRt2OnGVkr6(1B+!o={>Vq-ZQSHc@NRo2^zsFxL}?o+{Dl5O@fk#6 z>KQT}R~aZ=PVqTFcWI6WeV60Gw$LRV_{qvJ1M*U&TOn_JCn{VOWaC4cVBpETkxK3R`Xw~0693W0=iG{TYyodLD`RU^4 zd_R&2Svjxf(9d6tr7@pIvG5&K<)HW*BHu!d9u$8?WO=G^h+%)q!KIZcKFZ4U@94`a zFEF?deLAZg;>s~%qO1}!QI2I*iHW^HW*_}oH5)qyDF=)d?IJsD69M+!cnIA=Lhv5Zk#@34U%(Em8Uwei1^(hzxxVNDKFaq$ut zgJFV~y8Hx&49GaLBdRQ2rq`{7?uHy|flwwTw+Z=`3f=t4eJXdC)0G)z)~9PMU1^Z4 zc)GX`ZTb+`zLxfhvLY9Pf8Xk3wn+` p@ajPbn3K1IJg&h>k7Ay)2phM+cbsdB{6D~FoXOkd5mvE=?7#bn22 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 0000000000000000000000000000000000000000..1d5d2142a13f7bc89c5feb505c3357173b568fe8 GIT binary patch literal 843 zcmb7?O>Yx15Qbl;Nj6PVTGA9KUrqUH0usIY_{>!ca@RP(|91=D>2X%sdep8 z=)Q0&`14@i@2P~L)%{0)o1w5524tu=TYq1IVSP6>Ud6Jn5=DI;8)Loj${K2OziZu? zC)w8CIuXl5>)!E0Ip70jMqC_g`L5hgW#V_lbQ*R;T@Qp#=@vykZ-4JUSjm*y%WXTF z5vkm>sT;~CDlDb`$NuhyAIEU#R5-m5C#|1NCI7YYHa2mdUSarhpg~b2yG|ablhIkY z{RQk}mcB?fq(SfS64~mJ0GDxvJcg^-AV?^Fkime;Cq%WS&seUleV}j-0TEt(C@x{? i1g0{_G$>ai#U=r-y#Y&b9XBYJ!_CazLQsS;wt%1Wz}1%k literal 0 HcmV?d00001 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