guanpengchn / guanpengchn.github.io

:memo: code on DEV branch, blogs on ISSUES
https://guanpengchn.github.io
18 stars 8 forks source link

Spring Boot工程目录结构 #66

Open guanpengchn opened 5 years ago

guanpengchn commented 5 years ago

代码层的结构

src/main/java/com.example                   // 根目录
  ├── Application.java                      // 启动类
  ├── domain(jpa) / pojo(mybatis)           // 实体类(domain)
  ├── repository(jpa) / mapper(mybatis)     // 数据访问层(Dao)
  ├── service                               // 数据服务层(Service)
  │   └── impl                              // 数据服务层实现接口(ServiceImpl)
  ├── controller                            // 前端控制器(Controller)
  ├── utils                                 // 工具类(Utils)
  ├── consist                               // 常量接口类(Consist)
  ├── config                                // 配置信息类(Config)
  ├── dto                                   // 数据传输对象(DTO)
  └── vo                                    // 视图对象(VO)

资源文件的结构

src/main/resources                          // 根目录
  ├── config                                // 配置文件(.properties/.json等)
  ├── i18n                                  // 国际化(i18n)
  ├── META-INF/spring                       // spring.xml
  └── static                                // 静态文件夹        
      ├── css                               // css文件
      ├── js                                // js文件
      ├── image                             // 图片
      └── templates                         // html文件    

如果业务过多,可对不同业务做内聚,在业务内部再细分结构,如下图所示

2038160447-58fede3bec1fa_articlex