diff --git a/SpringBoot-Moudle/.gitignore b/SpringBoot-Moudle/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d8fe4fa70f618843e9ab2df67167b49565c71f25 --- /dev/null +++ b/SpringBoot-Moudle/.gitignore @@ -0,0 +1 @@ +/.project diff --git a/SpringBoot-Moudle/README.en.md b/SpringBoot-Moudle/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..671b00daf3d1132cdf60a7cad324511c7dc05a10 --- /dev/null +++ b/SpringBoot-Moudle/README.en.md @@ -0,0 +1,22 @@ +# SpringBoot-Moudle + +#### Description +springboot分模块项目构建 + +#### Software Architecture +本次构建主要包含web(springboot-web)子项目,service(springboot-service)业务相关子项目,dao(springboot-dao)数据库操作相关子项目. + +#### Construction process +https://blog.csdn.net/qq_26709459/article/details/85147585 + +#### Installation + +1. 创建数据库及数据库表 +2. 修改springboot-web中application.yml中对应的数据库配置 +2. 启动springboot-web中的main方法即可 + +#### Instructions + +1. 访问地址: +http://localhost:8080/button/user/getUser + diff --git a/SpringBoot-Moudle/README.md b/SpringBoot-Moudle/README.md new file mode 100644 index 0000000000000000000000000000000000000000..af0b20bf81a70fa108c82009336c64e33150b2eb --- /dev/null +++ b/SpringBoot-Moudle/README.md @@ -0,0 +1,23 @@ +# SpringBoot-Moudle + +#### 介绍 +springboot分模块项目构建 + +#### 软件架构 +本次构建主要包含web(springboot-web)子项目,service(springboot-service)业务相关子项目,dao(springboot-dao)数据库操作相关子项目. + +#### 搭建过程 +https://blog.csdn.net/qq_26709459/article/details/85147585 + +#### 安装教程 + +1. 创建数据库及数据库表 +2. 修改springboot-web中application.yml中对应的数据库配置 +2. 启动springboot-web中的main方法即可 + +#### 使用说明 + +1. 访问地址: +http://localhost:8080/button/user/getUser + + diff --git a/SpringBoot-Moudle/button_boot.sql b/SpringBoot-Moudle/button_boot.sql new file mode 100644 index 0000000000000000000000000000000000000000..6528d0832bb74c2e96308dd74e70717b72ab30bf --- /dev/null +++ b/SpringBoot-Moudle/button_boot.sql @@ -0,0 +1,11 @@ +create database if not exists button_boot; + + +CREATE TABLE `button_boot`.`tb_user` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `name` VARCHAR(10) NULL DEFAULT NULL, + `age` INT(3) NULL DEFAULT NULL, + PRIMARY KEY (`id`)) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8 +COLLATE = utf8_bin; diff --git a/SpringBoot-Moudle/pom.xml b/SpringBoot-Moudle/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4f2fc295f9b8e8e32c696e8d677dc53ae68e711d --- /dev/null +++ b/SpringBoot-Moudle/pom.xml @@ -0,0 +1,129 @@ + + SpringBoot分模块 + 4.0.0 + com.button + springboot-parent + 0.0.1-SNAPSHOT + pom + + + UTF-8 + UTF-8 + 1.8 + 0.0.1-SNAPSHOT + 0.0.1-SNAPSHOT + 0.0.1-SNAPSHOT + 0.0.1-SNAPSHOT + 1.1.1 + 2.4.13 + 5.0.0 + 1.2.3 + 1.2.3 + 2.2.2 + + + + + nexus + Nexus Repository + http://www.radiobutton.shop:8991/nexus/content/groups/public/ + + true + + + true + + + + + + + org.springframework.boot + spring-boot-starter-parent + 2.0.1.RELEASE + + + + + springboot-web + springboot-service + springboot-dao + springboot-entity + + + + + + + com.button + springboot-web + ${springboot-web.version} + + + com.button + springboot-service + ${springboot-service.version} + + + com.button + springboot-dao + ${springboot-dao.version} + + + com.button + springboot-entity + ${springboot-entity.version} + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${mybatis-spring-boot-starter.version} + + + + com.zaxxer + HikariCP-java7 + ${HikariCP.version} + + + + com.github.pagehelper + pagehelper + ${pagehelper.version} + + + com.github.pagehelper + pagehelper-spring-boot-autoconfigure + ${pagehelper-spring-boot-autoconfigure.version} + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper-spring-boot-starter.version} + + + + net.sf.json-lib + json-lib + ${json-lib.version} + jdk15 + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-dao/.gitignore b/SpringBoot-Moudle/springboot-dao/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..525681cae96875b1ac853e2d297438e646d48433 --- /dev/null +++ b/SpringBoot-Moudle/springboot-dao/.gitignore @@ -0,0 +1,3 @@ +/target/ +/.classpath +/.project diff --git a/SpringBoot-Moudle/springboot-dao/pom.xml b/SpringBoot-Moudle/springboot-dao/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f2402a9959f405b3a3092ef12e0080e8f3ebc44 --- /dev/null +++ b/SpringBoot-Moudle/springboot-dao/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + springboot-dao + jar + springboot-dao + + com.button + springboot-parent + 0.0.1-SNAPSHOT + + + + + nexus + Nexus Repository + http://www.radiobutton.shop:8991/nexus/content/groups/public/ + + true + + + true + + + + + + + com.button + springboot-entity + + + org.springframework.boot + spring-boot-starter-aop + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.apache.tomcat + tomcat-jdbc + + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + + + + mysql + mysql-connector-java + + + com.zaxxer + HikariCP-java7 + + + + + com.github.pagehelper + pagehelper + + + com.github.pagehelper + pagehelper-spring-boot-autoconfigure + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + + + src/main/resources + + **/*.xml + + + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-dao/src/main/java/com/button/project/dao/UserMapper.java b/SpringBoot-Moudle/springboot-dao/src/main/java/com/button/project/dao/UserMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..0b2a302b0b2e3c5814852a9946a81158aa24fdd9 --- /dev/null +++ b/SpringBoot-Moudle/springboot-dao/src/main/java/com/button/project/dao/UserMapper.java @@ -0,0 +1,12 @@ +package com.button.project.dao; + +import java.util.List; + +import org.apache.ibatis.annotations.Mapper; + +import com.button.project.pojo.UserModel; + +@Mapper +public interface UserMapper { + List getUser(); +} diff --git a/SpringBoot-Moudle/springboot-dao/src/main/resources/config/application-mybatis.xml b/SpringBoot-Moudle/springboot-dao/src/main/resources/config/application-mybatis.xml new file mode 100644 index 0000000000000000000000000000000000000000..8937e79b43f83eee2e11dae5ea909068ea8ac0ba --- /dev/null +++ b/SpringBoot-Moudle/springboot-dao/src/main/resources/config/application-mybatis.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-dao/src/main/resources/mapper/UserMapper.xml b/SpringBoot-Moudle/springboot-dao/src/main/resources/mapper/UserMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..80f797583562b59a0b4e8c2ad3a97754a8a65523 --- /dev/null +++ b/SpringBoot-Moudle/springboot-dao/src/main/resources/mapper/UserMapper.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-entity/.gitignore b/SpringBoot-Moudle/springboot-entity/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..525681cae96875b1ac853e2d297438e646d48433 --- /dev/null +++ b/SpringBoot-Moudle/springboot-entity/.gitignore @@ -0,0 +1,3 @@ +/target/ +/.classpath +/.project diff --git a/SpringBoot-Moudle/springboot-entity/pom.xml b/SpringBoot-Moudle/springboot-entity/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a88c6f671bee80dfbbdf14926d6e8ba6920e5fdc --- /dev/null +++ b/SpringBoot-Moudle/springboot-entity/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + springboot-entity + jar + springboot-entity + + + + nexus + Nexus Repository + http://www.radiobutton.shop:8991/nexus/content/groups/public/ + + true + + + true + + + + + + com.button + springboot-parent + 0.0.1-SNAPSHOT + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-entity/src/main/java/com/button/project/pojo/UserModel.java b/SpringBoot-Moudle/springboot-entity/src/main/java/com/button/project/pojo/UserModel.java new file mode 100644 index 0000000000000000000000000000000000000000..f5eea99acd72a5004e152d278922cc0928eb3b68 --- /dev/null +++ b/SpringBoot-Moudle/springboot-entity/src/main/java/com/button/project/pojo/UserModel.java @@ -0,0 +1,32 @@ +package com.button.project.pojo; + +import java.io.Serializable; + +public class UserModel implements Serializable{ + private static final long serialVersionUID = 1L; + private Integer id; + private String name; + private Integer age; + public Integer getId() { + return id; + } + public void setId(Integer 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; + } + @Override + public String toString() { + return "UserModel [id=" + id + ", name=" + name + ", age=" + age + "]"; + } +} diff --git a/SpringBoot-Moudle/springboot-service/.gitignore b/SpringBoot-Moudle/springboot-service/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..525681cae96875b1ac853e2d297438e646d48433 --- /dev/null +++ b/SpringBoot-Moudle/springboot-service/.gitignore @@ -0,0 +1,3 @@ +/target/ +/.classpath +/.project diff --git a/SpringBoot-Moudle/springboot-service/pom.xml b/SpringBoot-Moudle/springboot-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3f2ca115ce8e18dc3cc67c02f5584ad05c97746d --- /dev/null +++ b/SpringBoot-Moudle/springboot-service/pom.xml @@ -0,0 +1,36 @@ + + 4.0.0 + springboot-service + jar + springboot-service + + com.button + springboot-parent + 0.0.1-SNAPSHOT + + + + + nexus + Nexus Repository + http://www.radiobutton.shop:8991/nexus/content/groups/public/ + + true + + + true + + + + + + com.button + springboot-dao + + + org.springframework + spring-context-support + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/UserService.java b/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/UserService.java new file mode 100644 index 0000000000000000000000000000000000000000..211a733b29b1184784b8a0fdac81d585b9ebab1d --- /dev/null +++ b/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/UserService.java @@ -0,0 +1,9 @@ +package com.button.project.service; + +import java.util.List; + +import com.button.project.pojo.UserModel; + +public interface UserService { + List getUser(); +} diff --git a/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/impl/UserServiceImpl.java b/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/impl/UserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..21fec7af6d92354040abb7b8f53a386240814d49 --- /dev/null +++ b/SpringBoot-Moudle/springboot-service/src/main/java/com/button/project/service/impl/UserServiceImpl.java @@ -0,0 +1,23 @@ +package com.button.project.service.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.button.project.dao.UserMapper; +import com.button.project.pojo.UserModel; +import com.button.project.service.UserService; + +@Service +public class UserServiceImpl implements UserService { + + @Autowired + private UserMapper userMapper; + + @Override + public List getUser() { + return userMapper.getUser(); + } + +} diff --git a/SpringBoot-Moudle/springboot-web/.gitignore b/SpringBoot-Moudle/springboot-web/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..525681cae96875b1ac853e2d297438e646d48433 --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/.gitignore @@ -0,0 +1,3 @@ +/target/ +/.classpath +/.project diff --git a/SpringBoot-Moudle/springboot-web/pom.xml b/SpringBoot-Moudle/springboot-web/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..541701c71248e6f8c1efcdfcd959ef1d611b61b1 --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + springboot-web + jar + springboot-web + + com.button + springboot-parent + 0.0.1-SNAPSHOT + + + + + + com.button + springboot-service + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + -Dfile.encoding=UTF-8 + true + + + + + \ No newline at end of file diff --git a/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/SpringBootApplicationService.java b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/SpringBootApplicationService.java new file mode 100644 index 0000000000000000000000000000000000000000..b04a2aec2131d8f82180ff30c7da397edb8f1a12 --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/SpringBootApplicationService.java @@ -0,0 +1,21 @@ +package com.button.project; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@ImportResource("classpath:config/application-mybatis.xml") +@ServletComponentScan +@EnableCaching +@EnableTransactionManagement +@SpringBootApplication +public class SpringBootApplicationService { + //项目启动入口 + public static void main(String[] args) { + SpringApplication.run(SpringBootApplicationService.class, args); + } +} + diff --git a/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/UserController.java b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/UserController.java new file mode 100644 index 0000000000000000000000000000000000000000..f3a0543ad084d7c962f908cf5ce12db837725d95 --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/UserController.java @@ -0,0 +1,15 @@ +package com.button.project.controller; + +import java.util.List; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import com.button.project.pojo.UserModel; + +@RequestMapping(value = "/user", produces = "application/json;charset=UTF-8") +public interface UserController { + + @RequestMapping(value = "/getUser", method={RequestMethod.POST, RequestMethod.GET}) + List getUser(); +} diff --git a/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/impl/UserControllerImpl.java b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/impl/UserControllerImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e354671b3965604e96fda58cc5e6af3ac2fe290c --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/controller/impl/UserControllerImpl.java @@ -0,0 +1,23 @@ +package com.button.project.controller.impl; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RestController; + +import com.button.project.controller.UserController; +import com.button.project.pojo.UserModel; +import com.button.project.service.UserService; + +@RestController +public class UserControllerImpl implements UserController { + + @Autowired + private UserService userService; + + @Override + public List getUser() { + return userService.getUser(); + } + +} diff --git a/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/init/InitConstantListener.java b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/init/InitConstantListener.java new file mode 100644 index 0000000000000000000000000000000000000000..e421a6c15aae7a31b2131c21122ca447c1e1b427 --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/java/com/button/project/init/InitConstantListener.java @@ -0,0 +1,24 @@ +package com.button.project.init; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.annotation.WebListener; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@WebListener +public class InitConstantListener implements ServletContextListener { + private static final Logger logger = LoggerFactory.getLogger(InitConstantListener.class); + + @Override + public void contextInitialized(ServletContextEvent sce) { + logger.info("初始化数据."); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + logger.info("销毁数据."); + } + +} diff --git a/SpringBoot-Moudle/springboot-web/src/main/resources/application.yml b/SpringBoot-Moudle/springboot-web/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..bac7e12adaa3261b0be531b302741a972e899bcf --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/resources/application.yml @@ -0,0 +1,38 @@ +server: + servlet: + context-path: /button + port: 8080 + uri-encoding: utf-8 + +logging: + config: classpath:logback.xml + +spring: + dataSource: + url: jdbc:mysql://localhost:3306/button_boot?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true&useSSL=true + username: root + password: 211314 + driver-class-name: com.mysql.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + hikari: + minimum-idle: 5 + maximum-pool-size: 15 + idle-timeout: 30000 + pool-name: DatebookHikariCP + max-lifetime: 1800000 + connection-timeout: 30000 + connection-test-query: 'SELECT 1' + +mybatis: + # 加载mapper + mapper-locations: "classpath:mapper/*.xml" + +mapper: + not-empty: false + identity: MYSQL + +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql diff --git a/SpringBoot-Moudle/springboot-web/src/main/resources/logback.xml b/SpringBoot-Moudle/springboot-web/src/main/resources/logback.xml new file mode 100644 index 0000000000000000000000000000000000000000..46d881bf44f76a93a2d3cf8e835780d5e4ee5f4c --- /dev/null +++ b/SpringBoot-Moudle/springboot-web/src/main/resources/logback.xml @@ -0,0 +1,30 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + ${LOG_HOME}/springboot.log + + + ${LOG_HOME}/springboot.log.%d{yyyy-MM-dd}.%i.log + + + 100MB + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} -%msg%n + + + + + + + + \ No newline at end of file diff --git a/SpringBoot-ShardingJdbc/.gitignore b/SpringBoot-ShardingJdbc/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/SpringBoot-ShardingJdbc/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/Springboot-File-Upload-Download/.gitignore b/Springboot-File-Upload-Download/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..b83d22266ac8aa2f8df2edef68082c789727841d --- /dev/null +++ b/Springboot-File-Upload-Download/.gitignore @@ -0,0 +1 @@ +/target/