diboot/diboot-docs/guide/notes/upgrade.md

3.6 KiB
Raw Blame History

版本升级向导

diboot v2.0.x 升级至 v2.1.x

1. diboot-core

  • v2.1.x 版本开始BaseCrudRestController移除了方法中的request参数改为在BaseController中统一注入以简化继承代码。 子类需要时直接用request变量即可无需再定义request参数。 修改: 调用父类方法的Controller方法需删除方法中的request参数定义及传递。 示例:
public JsonResult getDepartmentVOList(DepartmentDto departmentDto, HttpServletRequest request) throws Exception{
    QueryWrapper<Department> queryWrapper = super.buildQueryWrapper(departmentDto, request);
    ...
}

修改为

public JsonResult getDepartmentVOList(DepartmentDto departmentDto) throws Exception{
    QueryWrapper<Department> queryWrapper = super.buildQueryWrapper(departmentDto);
    ...
}
  • v2.1.x 版本开始BaseCrudRestController移除了VO泛型参数便于子类灵活指定不同VO同时父类方法getViewObject*增加VO class参数用于指定VO。 修改示例:
public class DepartmentController extends BaseCustomCrudRestController<Department, DepartmentVO> {
    ...
    super.getViewObjectList(entity, pagination);
}

修改为

public class DepartmentController extends BaseCustomCrudRestController<Department> {
    ...
    super.getViewObjectList(entity, pagination, DepartmentVO.class);
}
  • v2.1.x版本开始新增了通用的/common/attachMore接口用于统一提供key-value形式数据用于select下拉框等组件。 建议升级步骤:

    • 备份DictionaryController及各Base基础代码
    • 启动diboot-devtools在组件初始化页面找到diboot-core点击生成代码
    • 将你改动过的Base基础代码合并至新生成的类
  • v2.1.x版本开始core-starter中不再默认指定Date类型转json的默认格式而是通过Date字段注解@JSONField(format=)去指定。 如果Date日期格式非预期您可以通过以下两种方式调整

  1. 需要在Date字段上添加@JSONField(format=)注解。 或
  2. 重新定义HttpMessageConverters统一指定Date类型默认格式。
  • v2.1.x版本core-starter自动初始化增加了String-Date转换的convertor至Spring FormatterRegistry。 如果您不需要request查询参数的String转Date可重写addFormatters移除String-Date转换。
@Override
public void addFormatters(FormatterRegistry registry) {
   registry.removeConvertible(String.class, Date.class);
}
  • v2.1.x版本开始extdata扩展字段将不再推荐使用该字段设计目的用于字段冗余的json存储可以通过数据库的json数据类型实现。 devtools从2.1版本开始不再支持extdata的特殊处理。

  • v2.1.x版本依赖组件升级为: Spring Boot 2.3.xMybatis-Plus 3.3.xfastjson 1.2.7x。根据您的依赖情况,可能会有依赖冲突需要解决。

2. diboot-devtools

  • v2.1版本开始,配置参数: 新增 diboot.devtools.output-path 代码的生成根路径配置项, 如entity, dto, controller, mapper, service, vo等路径无自定义需求仅配置该根路径即可。 示例:
diboot.devtools.output-path=example/src/main/java/com/diboot/example/

同时开放更多的自定义配置项,如:

diboot.devtools.output-path-mapper-xml=
diboot.devtools.output-path-service-impl=
diboot.devtools.output-path-dto=
diboot.devtools.output-path-exception-handler=

v2.1.x版本开始支持前端代码生成如果需要该功能则需配置。如

diboot.devtools.output-path-frontend=/Workspace/diboot-antd-admin-ent/

3. diboot-iam