diff --git a/demo2/.gitignore b/demo2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5ff6309b7199129c1afe4f4ec1906e640bec48c6 --- /dev/null +++ b/demo2/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/demo2/.idea/.gitignore b/demo2/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/demo2/.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 diff --git a/demo2/.idea/artifacts/demo2_war_exploded.xml b/demo2/.idea/artifacts/demo2_war_exploded.xml new file mode 100644 index 0000000000000000000000000000000000000000..defb2bbff9b97662f89be9df4fa65305f226aa33 --- /dev/null +++ b/demo2/.idea/artifacts/demo2_war_exploded.xml @@ -0,0 +1,13 @@ + + + $PROJECT_DIR$/out/artifacts/demo2_war_exploded + + + + + + + + + + \ No newline at end of file diff --git a/demo2/.idea/encodings.xml b/demo2/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa00ffab7828f4818589659c804ec2cfd99baed3 --- /dev/null +++ b/demo2/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/demo2/.idea/misc.xml b/demo2/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..132404bc29da2535f7f7dde84180d85abc60d5a4 --- /dev/null +++ b/demo2/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/demo2/pom.xml b/demo2/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..354b10ea2ba09c6a6c8851b4695067fbf8bb0c00 --- /dev/null +++ b/demo2/pom.xml @@ -0,0 +1,161 @@ + + + 4.0.0 + + + + + org.mybatis + mybatis + 3.5.6 + + + org.mybatis + mybatis-spring + 2.0.6 + + + commons-logging + commons-logging + 1.2 + + + org.springframework + spring-aop + 5.3.2 + + + org.springframework + spring-beans + 5.3.2 + + + org.springframework + spring-context + 5.3.2 + + + org.springframework + spring-core + 5.3.2 + + + org.springframework + spring-expression + 5.3.2 + + + org.springframework + spring-jdbc + 5.3.2 + + + org.springframework + spring-tx + 5.3.2 + + + org.springframework + spring-web + 5.3.2 + + + org.springframework + spring-webmvc + 5.3.2 + + + + mysql + mysql-connector-java + 5.1.45 + + + + org.apache.commons + commons-dbcp2 + 2.8.0 + + + org.apache.commons + commons-pool2 + 2.9.0 + + + + log4j + log4j + 1.2.12 + + + org.apache.logging.log4j + log4j-api + 2.17.2 + + + org.apache.logging.log4j + log4j-core + 2.17.2 + + + + javax.servlet + servlet-api + 2.5 + + + javax.servlet + javax.servlet-api + 3.0.1 + + + javax.servlet.jsp + javax.servlet.jsp-api + 2.2.1 + + + + junit + junit + 4.12 + + + + org.json + json + 20160810 + + + + com.google.code.gson + gson + 2.8.5 + + + + com.alibaba + fastjson + 1.2.47 + + + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + + + + + org.example + demo2 + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + + + \ No newline at end of file diff --git a/demo2/src/main/java/com/mustgo/alpha/Main.java b/demo2/src/main/java/com/mustgo/alpha/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..e6b0a31b6eff95485c2e398a7fd68c763ac94c8c --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/Main.java @@ -0,0 +1,7 @@ +package com.mustgo.alpha; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/demo2/src/main/java/com/mustgo/alpha/controller/UserController.java b/demo2/src/main/java/com/mustgo/alpha/controller/UserController.java new file mode 100644 index 0000000000000000000000000000000000000000..1b8073593bc3e97fb1219128a2fbf82647159e89 --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/controller/UserController.java @@ -0,0 +1,27 @@ +package com.mustgo.alpha.controller; + +import com.mustgo.alpha.model.MyUser; +import com.mustgo.alpha.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class UserController { + @Autowired + private UserService userService; + + @RequestMapping("/register") + @ResponseBody + public String test(){ + System.out.println("get a request:register"); + + MyUser myUser = new MyUser(); + myUser.setId(1); + myUser.setUname("sb"); + myUser.setUpwd("123456"); + userService.register(myUser); + return "register success"; + } +} diff --git a/demo2/src/main/java/com/mustgo/alpha/dao/UserMapper.java b/demo2/src/main/java/com/mustgo/alpha/dao/UserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..310776a7d752969f9fdb8205b07f06feac06eecb --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/dao/UserMapper.java @@ -0,0 +1,7 @@ +package com.mustgo.alpha.dao; + +import com.mustgo.alpha.model.MyUser; + +public interface UserMapper { + void register(MyUser myUser); +} diff --git a/demo2/src/main/java/com/mustgo/alpha/model/MyUser.java b/demo2/src/main/java/com/mustgo/alpha/model/MyUser.java new file mode 100644 index 0000000000000000000000000000000000000000..036d09803a914477b9d86dccf7cd0a1712f871b6 --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/model/MyUser.java @@ -0,0 +1,31 @@ +package com.mustgo.alpha.model; + +public class MyUser { + private int id; + private String uname; + private String upwd; + + public int getId() { + return id; + } + + public String getUname() { + return uname; + } + + public String getUpwd() { + return upwd; + } + + public void setId(int id) { + this.id = id; + } + + public void setUname(String uname) { + this.uname = uname; + } + + public void setUpwd(String upwd) { + this.upwd = upwd; + } +} diff --git a/demo2/src/main/java/com/mustgo/alpha/po/MyUserTable.java b/demo2/src/main/java/com/mustgo/alpha/po/MyUserTable.java new file mode 100644 index 0000000000000000000000000000000000000000..9e4bff0c24f1d14ab1448c125490250b4aca9b50 --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/po/MyUserTable.java @@ -0,0 +1,31 @@ +package com.mustgo.alpha.po; + +public class MyUserTable { + private int id; + private String uname; + private String upwd; + + public int getId() { + return id; + } + + public String getUname() { + return uname; + } + + public String getUpwd() { + return upwd; + } + + public void setId(int id) { + this.id = id; + } + + public void setUname(String uname) { + this.uname = uname; + } + + public void setUpwd(String upwd) { + this.upwd = upwd; + } +} diff --git a/demo2/src/main/java/com/mustgo/alpha/service/UserService.java b/demo2/src/main/java/com/mustgo/alpha/service/UserService.java new file mode 100644 index 0000000000000000000000000000000000000000..6a3efe4ff62802acd352b383733bd257b9cfd7ac --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/service/UserService.java @@ -0,0 +1,7 @@ +package com.mustgo.alpha.service; + +import com.mustgo.alpha.model.MyUser; + +public interface UserService { + void register(MyUser myUser); +} diff --git a/demo2/src/main/java/com/mustgo/alpha/service/UserServiceImpl.java b/demo2/src/main/java/com/mustgo/alpha/service/UserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8f78e9cb2b62a66a84ff29a72c3cb9f34a576afa --- /dev/null +++ b/demo2/src/main/java/com/mustgo/alpha/service/UserServiceImpl.java @@ -0,0 +1,31 @@ +package com.mustgo.alpha.service; + +import com.mustgo.alpha.dao.UserMapper; +import com.mustgo.alpha.model.MyUser; +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; + +import java.io.IOException; +import java.io.InputStream; + +public class UserServiceImpl implements UserService{ + + @Override + public void register(MyUser myUser) { + try { + InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml"); + SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream); + SqlSession sqlSession = sqlSessionFactory.openSession(); + + UserMapper userMapper = sqlSession.getMapper(UserMapper.class); + userMapper.register(myUser); + + sqlSession.commit(); + sqlSession.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/demo2/src/main/resources/applicationContext.xml b/demo2/src/main/resources/applicationContext.xml new file mode 100644 index 0000000000000000000000000000000000000000..28ffa08c35825adb18776977d9ab5b21da24931b --- /dev/null +++ b/demo2/src/main/resources/applicationContext.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/demo2/src/main/resources/jdbs.properties b/demo2/src/main/resources/jdbs.properties new file mode 100644 index 0000000000000000000000000000000000000000..6a4bf42c6ef972c9ebc3d6c3f542ab3dfdd98297 --- /dev/null +++ b/demo2/src/main/resources/jdbs.properties @@ -0,0 +1,4 @@ +jdbc.driver=com.cj.mysql.jdbc.Driver +jdbc.url=jdbc:mysql://111.229.222.154:3306/mustgo?characterEncoding=utf8&useSSL=false +jdbc.username=root +jdbc.password= diff --git a/demo2/src/main/resources/mapper/UserMapper.xml b/demo2/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..2715ad5efa1ff91ce6e9ad7eb9de535eaf4be9dc --- /dev/null +++ b/demo2/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/demo2/src/main/resources/springmvc.xml b/demo2/src/main/resources/springmvc.xml new file mode 100644 index 0000000000000000000000000000000000000000..fa961b88ecec8691921444cad32fa273f8735d5e --- /dev/null +++ b/demo2/src/main/resources/springmvc.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + diff --git a/demo2/src/main/resources/sqlMapConfig.xml b/demo2/src/main/resources/sqlMapConfig.xml new file mode 100644 index 0000000000000000000000000000000000000000..c1bcc342fac3c29f5302f180c807007748378929 --- /dev/null +++ b/demo2/src/main/resources/sqlMapConfig.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo2/web/WEB-INF/web.xml b/demo2/web/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..9cb67ffd46f41c63fad38727b265959d0252fbdc --- /dev/null +++ b/demo2/web/WEB-INF/web.xml @@ -0,0 +1,44 @@ + + + + + contextConfigLocation + classpath:applicationContext.xml + + + + org.springframework.web.context.ContextLoaderListener + + + + DispatcherServlet + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + classpath:springmvc.xml + + 1 + + + + DispatcherServlet + / + + + + CharacterEncodingFilter + org.springframework.web.filter.CharacterEncodingFilter + + encoding + UTF-8 + + + + CharacterEncodingFilter + /* + + + diff --git a/demo2/web/index.jsp b/demo2/web/index.jsp new file mode 100644 index 0000000000000000000000000000000000000000..b745a5e3e417da7dbad6f530c24442d4c7dce500 --- /dev/null +++ b/demo2/web/index.jsp @@ -0,0 +1,16 @@ +<%-- + Created by IntelliJ IDEA. + User: 86152 + Date: 2023/4/26 + Time: 15:53 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + $Title$ + + + $END$ + +