Browse Source

提交项目

byh 2 weeks ago
commit
0fe525a986
43 changed files with 432 additions and 0 deletions
  1. 29 0
      .gitignore
  2. 8 0
      .idea/.gitignore
  3. 13 0
      .idea/artifacts/oneseven_war_exploded.xml
  4. 6 0
      .idea/encodings.xml
  5. 10 0
      .idea/libraries/lib.xml
  6. 6 0
      .idea/misc.xml
  7. 8 0
      .idea/modules.xml
  8. 24 0
      oneseven.iml
  9. 5 0
      src/Main.java
  10. 31 0
      src/gydx/springmybatis/bo/StudentVO.java
  11. 47 0
      src/gydx/springmybatis/controller/StudentController.java
  12. 77 0
      src/gydx/springmybatis/gydxSpring.xml
  13. 18 0
      src/gydx/springmybatis/mapper/StudentInterface.java
  14. 46 0
      src/gydx/springmybatis/mapper/student.xml
  15. 17 0
      src/gydx/springmybatis/service/StudentService.java
  16. 38 0
      src/gydx/springmybatis/service/StudentServiceImpl.java
  17. BIN
      web/WEB-INF/lib/aopalliance-.jar
  18. BIN
      web/WEB-INF/lib/aspectjweaver-1.8.9.jar
  19. BIN
      web/WEB-INF/lib/commons-dbcp2-2.12.0.jar
  20. BIN
      web/WEB-INF/lib/commons-logging-1.3.4.jar
  21. BIN
      web/WEB-INF/lib/commons-pool2-2.12.0.jar
  22. BIN
      web/WEB-INF/lib/jackson-annotations-2.2.2.jar
  23. BIN
      web/WEB-INF/lib/jackson-core-2.2.3.jar
  24. BIN
      web/WEB-INF/lib/jackson-databind-2.2.3.jar
  25. BIN
      web/WEB-INF/lib/mybatis-3.4.6.jar
  26. BIN
      web/WEB-INF/lib/mybatis-spring-1.3.0.jar
  27. BIN
      web/WEB-INF/lib/mysql-connector-j-8.0.31.jar
  28. BIN
      web/WEB-INF/lib/spring-aop-4.1.6.RELEASE.jar
  29. BIN
      web/WEB-INF/lib/spring-aspects-4.1.6.RELEASE.jar
  30. BIN
      web/WEB-INF/lib/spring-beans-4.1.6.RELEASE.jar
  31. BIN
      web/WEB-INF/lib/spring-context-4.1.6.RELEASE.jar
  32. BIN
      web/WEB-INF/lib/spring-context-support-4.1.6.RELEASE.jar
  33. BIN
      web/WEB-INF/lib/spring-core-4.1.6.RELEASE.jar
  34. BIN
      web/WEB-INF/lib/spring-expression-4.1.6.RELEASE.jar
  35. BIN
      web/WEB-INF/lib/spring-jdbc-4.1.6.RELEASE.jar
  36. BIN
      web/WEB-INF/lib/spring-orm-4.1.6.RELEASE.jar
  37. BIN
      web/WEB-INF/lib/spring-oxm-4.1.6.RELEASE.jar
  38. BIN
      web/WEB-INF/lib/spring-tx-4.1.6.RELEASE.jar
  39. BIN
      web/WEB-INF/lib/spring-web-4.1.6.RELEASE.jar
  40. BIN
      web/WEB-INF/lib/spring-webmvc-4.1.6.RELEASE.jar
  41. BIN
      web/WEB-INF/lib/spring-webmvc-portlet-4.1.6.RELEASE.jar
  42. 26 0
      web/WEB-INF/web.xml
  43. 23 0
      web/index.jsp

+ 29 - 0
.gitignore

@@ -0,0 +1,29 @@
+### IntelliJ IDEA ###
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 13 - 0
.idea/artifacts/oneseven_war_exploded.xml

@@ -0,0 +1,13 @@
+<component name="ArtifactManager">
+  <artifact type="exploded-war" name="oneseven:war exploded">
+    <output-path>$PROJECT_DIR$/out/artifacts/oneseven_war_exploded</output-path>
+    <root id="root">
+      <element id="javaee-facet-resources" facet="oneseven/web/Web" />
+      <element id="directory" name="WEB-INF">
+        <element id="directory" name="classes">
+          <element id="module-output" name="oneseven" />
+        </element>
+      </element>
+    </root>
+  </artifact>
+</component>

+ 6 - 0
.idea/encodings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
+    <file url="PROJECT" charset="UTF-8" />
+  </component>
+</project>

+ 10 - 0
.idea/libraries/lib.xml

@@ -0,0 +1,10 @@
+<component name="libraryTable">
+  <library name="lib">
+    <CLASSES>
+      <root url="file://$PROJECT_DIR$/web/WEB-INF/lib" />
+    </CLASSES>
+    <JAVADOC />
+    <SOURCES />
+    <jarDirectory url="file://$PROJECT_DIR$/web/WEB-INF/lib" recursive="false" />
+  </library>
+</component>

+ 6 - 0
.idea/misc.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/oneseven.iml" filepath="$PROJECT_DIR$/oneseven.iml" />
+    </modules>
+  </component>
+</project>

+ 24 - 0
oneseven.iml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="web" name="Web">
+      <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
+        </descriptors>
+        <webroots>
+          <root url="file://$MODULE_DIR$/web" relative="/" />
+        </webroots>
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="lib" level="project" />
+  </component>
+</module>

+ 5 - 0
src/Main.java

@@ -0,0 +1,5 @@
+public class Main {
+    public static void main(String[] args) {
+        System.out.println("Hello world!");
+    }
+}

+ 31 - 0
src/gydx/springmybatis/bo/StudentVO.java

@@ -0,0 +1,31 @@
+package gydx.springmybatis.bo;
+
+public class StudentVO {
+    private int id;
+    private String name;
+    private Integer age;
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+    public void setAge(Integer age) {
+        this.age = age;
+    }
+}

+ 47 - 0
src/gydx/springmybatis/controller/StudentController.java

@@ -0,0 +1,47 @@
+package gydx.springmybatis.controller;
+
+import gydx.springmybatis.bo.StudentVO;
+import gydx.springmybatis.service.StudentService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("student")
+public class StudentController {
+    @Resource
+    StudentService studentService;
+
+    @RequestMapping("addStudent")
+    public int addStudent(StudentVO vo){
+        studentService.saveStudent(vo);
+        System.out.println("Hello" +vo.getAge() + "的" + vo.getName());
+
+        return 1;
+    }
+
+
+    @RequestMapping("deleteStudent")
+    public int deleteStudent(StudentVO vo){
+        studentService.deleteStudent(vo);
+        return 1;
+    }
+
+    @RequestMapping("updateStudent")
+    public int updateStudent(StudentVO vo){
+        studentService.updateStudent(vo);
+        return 1;
+
+    }
+
+    @RequestMapping("queryStudent")
+    public List queryStudent(StudentVO vo){
+
+        return studentService.queryStudent(vo);
+
+    }
+    
+
+}

+ 77 - 0
src/gydx/springmybatis/gydxSpring.xml

@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
+       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
+">
+<!--json整合     需要导入 jackson-annotations-*.jar,jackson-core-.jar,jackson-databind-.jar -->
+    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
+    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
+        <property name="messageConverters">
+            <list>
+                <bean class="org.springframework.http.converter.StringHttpMessageConverter">
+                    <property name="supportedMediaTypes">
+                        <list>
+                            <value>text/html; charset=UTF-8</value>
+                            <value>application/json;charset=UTF-8</value>
+                        </list>
+                    </property>
+                </bean>
+                <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
+                    <property name="supportedMediaTypes">
+                        <list>
+                            <value>text/html; charset=UTF-8</value>
+                            <value>application/json;charset=UTF-8</value>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+    </bean>
+
+
+
+<!--    扫描包下所有类,为添加了@Service、@Component、@Controller、@Repository修饰的类创建对象并存入IOC容器-->
+    <context:component-scan base-package="gydx.springmybatis.controller"></context:component-scan>
+    <mvc:default-servlet-handler></mvc:default-servlet-handler>
+    <mvc:annotation-driven></mvc:annotation-driven>
+
+    <context:component-scan base-package="gydx.springmybatis.service"></context:component-scan>
+
+    <bean id="gydxdb" class="org.apache.commons.dbcp2.BasicDataSource">
+        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
+        <property name="url" value="jdbc:mysql://47.92.102.27:53306/gydx"></property>
+        <property name="username" value="gydx"></property>
+        <property name="password" value="gydx123456"></property>
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="gydxdb"></property>
+        <property name="mapperLocations" value="classpath:gydx/springmybatis/mapper/student.xml"></property>
+
+<!--        显示SQL-->
+        <property name="configuration">
+            <bean class="org.apache.ibatis.session.Configuration">
+                <property name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl" />
+            </bean>
+        </property>
+    </bean>
+
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
+        <property name="basePackage" value="gydx.springmybatis.mapper"></property>
+    </bean>
+
+    <bean id="transactionManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="gydxdb"></property>
+    </bean>
+
+
+
+</beans>

+ 18 - 0
src/gydx/springmybatis/mapper/StudentInterface.java

@@ -0,0 +1,18 @@
+package gydx.springmybatis.mapper;
+
+import gydx.springmybatis.bo.StudentVO;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public interface StudentInterface {
+    public void addStudent(StudentVO vo);
+
+    public void deleteStudent(StudentVO vo);
+
+    public void updateStudent(StudentVO vo);
+
+    public List queryStudent(StudentVO vo);
+
+}

+ 46 - 0
src/gydx/springmybatis/mapper/student.xml

@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="gydx.springmybatis.mapper.StudentInterface">
+    <parameterMap id="svo" type="gydx.springmybatis.bo.StudentVO"></parameterMap>
+    <resultMap id="rvo" type="gydx.springmybatis.bo.StudentVO"></resultMap>
+
+    <insert id="addStudent" parameterMap="svo">
+        insert into student (name,age) values (#{name},#{age})
+    </insert>
+
+    <delete id="deleteStudent" parameterMap="svo">
+        delete from student where id = #{id}
+    </delete>
+
+    <update id="updateStudent" parameterMap="svo">
+        update student
+        <set>
+            <trim suffixOverrides=",">
+                <if test="name != null and name != '' ">
+                    name = #{name},
+                </if>
+                <if test="age != null">
+                    age = #{age},
+                </if>
+            </trim>
+        </set>
+        where id = #{id}
+    </update>
+
+    <select id="queryStudent" parameterMap="svo" resultMap="rvo">
+        select id,name,age from student
+        <where>
+            1=1
+            <if test="name != null and name != '' ">
+                and name = #{name}
+            </if>
+            <if test="age != null">
+                and age = #{age}
+            </if>
+        </where>
+    </select>
+
+
+</mapper>

+ 17 - 0
src/gydx/springmybatis/service/StudentService.java

@@ -0,0 +1,17 @@
+package gydx.springmybatis.service;
+
+import gydx.springmybatis.bo.StudentVO;
+
+import java.util.List;
+
+public interface StudentService {
+    public void saveStudent(StudentVO vo);
+
+    public void deleteStudent(StudentVO vo);
+
+    public void updateStudent(StudentVO vo);
+
+    public List queryStudent(StudentVO vo);
+
+
+}

+ 38 - 0
src/gydx/springmybatis/service/StudentServiceImpl.java

@@ -0,0 +1,38 @@
+package gydx.springmybatis.service;
+
+import gydx.springmybatis.bo.StudentVO;
+import gydx.springmybatis.mapper.StudentInterface;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class StudentServiceImpl implements StudentService{
+    @Resource
+    StudentInterface studentInterface;
+    @Override
+    public void saveStudent(StudentVO vo) {
+        studentInterface.addStudent(vo);
+        System.out.println("save"+vo.getName()+"同学");
+
+    }
+
+    @Override
+    public void deleteStudent(StudentVO vo) {
+        studentInterface.deleteStudent(vo);
+
+    }
+
+    @Override
+    public void updateStudent(StudentVO vo) {
+        studentInterface.updateStudent(vo);
+
+    }
+
+    @Override
+    public List queryStudent(StudentVO vo) {
+        return studentInterface.queryStudent(vo);
+
+    }
+}

BIN
web/WEB-INF/lib/aopalliance-.jar


BIN
web/WEB-INF/lib/aspectjweaver-1.8.9.jar


BIN
web/WEB-INF/lib/commons-dbcp2-2.12.0.jar


BIN
web/WEB-INF/lib/commons-logging-1.3.4.jar


BIN
web/WEB-INF/lib/commons-pool2-2.12.0.jar


BIN
web/WEB-INF/lib/jackson-annotations-2.2.2.jar


BIN
web/WEB-INF/lib/jackson-core-2.2.3.jar


BIN
web/WEB-INF/lib/jackson-databind-2.2.3.jar


BIN
web/WEB-INF/lib/mybatis-3.4.6.jar


BIN
web/WEB-INF/lib/mybatis-spring-1.3.0.jar


BIN
web/WEB-INF/lib/mysql-connector-j-8.0.31.jar


BIN
web/WEB-INF/lib/spring-aop-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-aspects-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-beans-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-context-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-context-support-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-core-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-expression-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-jdbc-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-orm-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-oxm-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-tx-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-web-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-webmvc-4.1.6.RELEASE.jar


BIN
web/WEB-INF/lib/spring-webmvc-portlet-4.1.6.RELEASE.jar


+ 26 - 0
web/WEB-INF/web.xml

@@ -0,0 +1,26 @@
+<?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">
+
+
+<servlet>
+    <servlet-name>gydxmvc</servlet-name>
+    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+
+    <init-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>classpath:gydx/springmybatis/gydxSpring.xml</param-value>
+    </init-param>
+
+    <load-on-startup>1</load-on-startup>
+</servlet>
+
+    <servlet-mapping>
+        <servlet-name>gydxmvc</servlet-name>
+        <url-pattern>*.gydx</url-pattern>
+    </servlet-mapping>
+
+
+</web-app>

+ 23 - 0
web/index.jsp

@@ -0,0 +1,23 @@
+<%--
+  Created by IntelliJ IDEA.
+  User: ASUS
+  Date: 2024/10/18
+  Time: 16:48
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+    <title>$Title$</title>
+</head>
+<body>
+<form action="./student/addStudent.gydx">
+  <input type="text" name="name">
+  <br>
+  <input type="text" name="age">
+  <br>
+  <input type="submit">
+</form>
+
+</body>
+</html>