1.创建maven的空白工程,如下图所示:
2.GroupID和ArtifactId命名为com.chanchifeng和Springboot-DBUp-SHADOW,如下图所示:
3.设置项目的电脑位置,如下图所示:
4.将src删除,操作如下图所示:
5.分别创建3个模块,分别为dbexpand、mysql和website,创建完成后目录结构:
6.项目的整体结构如下图所示:
7.dbexpand/com.chanchifeng.dbexpand.DruidConfiguration:
1 | import com.alibaba.druid.support.http.StatViewServlet; |
8.dbexpand/com.chanchifeng.dbexpand.JpaConfiguration:
1 | import com.chanchifeng.dbexpand.jpa.repository.ExpandJpaRepositoryFactoryBean; |
9.dbexpand/com.chanchifeng.dbexpand.RedisConfig:
1 | import java.lang.reflect.InvocationTargetException; |
10.dbexpand/pom.xml:
1 |
|
11.mysql/com.chanchifeng.mysql.entity.Department:
1 | import org.springframework.format.annotation.DateTimeFormat; |
12.mysql/com.chanchifeng.mysql.entity.Role:
1 | import org.springframework.format.annotation.DateTimeFormat; |
13.mysql/com.chanchifeng.mysql.entity.User:
1 | import com.fasterxml.jackson.annotation.JsonBackReference; |
14.mysql/com.chanchifeng.mysql.model.DepartmentQo:
1 | public class DepartmentQo extends PageQo{ |
15.mysql/com.chanchifeng.mysql.model.PageQo:
1 | public class PageQo { |
16.mysql/com.chanchifeng.mysql.model.RoleQo:
1 | public class RoleQo extends PageQo{ |
17.mysql/com.chanchifeng.mysql.model.UserQo:
1 | import org.springframework.format.annotation.DateTimeFormat; |
18.mysql/com.chanchifeng.mysql.redis.DepartmentRedis:
1 | import com.chanchifeng.mysql.entity.Department; |
19.mysql/com.chanchifeng.mysql.redis.RoleRedis:
1 | import com.chanchifeng.mysql.entity.Role; |
20.mysql/com.chanchifeng.mysql.redis.UserRedis:
1 | import com.chanchifeng.mysql.entity.User; |
21.mysql/com.chanchifeng.mysql.repository.DepartmentRepository:
1 | import com.chanchifeng.dbexpand.jpa.repository.ExpandJpaRepository; |
22.mysql/com.chanchifeng.mysql.repository.RoleRepository:
1 | import com.chanchifeng.dbexpand.jpa.repository.ExpandJpaRepository; |
23.mysql/com.chanchifeng.mysql.repository.UserRepository:
1 | import com.chanchifeng.dbexpand.jpa.repository.ExpandJpaRepository; |
24.mysql/com.chanchifeng.mysql.service.DepartmentService:
1 | import com.chanchifeng.dbexpand.jpa.parameter.LinkEnum; |
25.mysql/com.chanchifeng.mysql.service.RoleService:
1 | import com.chanchifeng.dbexpand.jpa.parameter.LinkEnum; |
26.mysql/com.chanchifeng.mysql.service.UserService:
1 | import com.chanchifeng.dbexpand.jpa.parameter.LinkEnum; |
27.mysql/pom.xml:
1 |
|
28.website/com.chanchifeng.website.controller.DepartmentController:
1 | import com.chanchifeng.mysql.entity.Department; |
29.website/com.chanchifeng.website.controller.RoleController:
1 | import com.chanchifeng.mysql.entity.Role; |
30.website/com.chanchifeng.website.controller.UserController:
1 | import com.chanchifeng.mysql.entity.Department; |
31.website/com.chanchifeng.website.WebApplication:
1 | import org.springframework.boot.SpringApplication; |
32.website/application.yml:
1 | server: |
33.website/pom.xml:
1 |
|
34.根目录下的pom.xml:
1 |
|
35.运行项目后可以在浏览器中输入http://localhost/user/index,测试项目的功能,效果如下图所示:
36.运行项目后可以在浏览器中输入http://localhost/druid/,账号密码分别为druid和123456(dbexpand/com.chanchifeng.dbexpand.DruidConfiguration),效果如下图所示:
Github : (SpringBoot-Sample/Springboot-DBUp-SHADOW)[https://github.com/porschan/SpringBoot-Sample]