【Java后端】Spring,SpringBoot注解相关问题

目录

Spring,SpringBoot注解相关问题

  • 1.@JsonFormat解决 Date类型格式的转换
  • 2.@Schema导致Error creating bean with name 'swaggerFacadeOpenApiProvider' defined in URL [jar:file:/D:/maven/repo-gscp/com/linewell/gov/hoox/gov-hoox-swagger/1.0.2/gov-hoox-


文章所属专区 日积月累


1.@JsonFormat解决 Date类型格式的转换

@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”,timezone=“GMT+8”)
pattern:日期格式类型 timezone:时区
也可以手动封装方法来转换时间格式

	private static DateTimeFormatter FORMATTER_YYYY_MM_DD_HH_MM_SS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    public static String formatToFORMATTER_YYYY_MM_DD_HH_MM_SS(Date date) {
        if(date == null) {
            return null;
        }
        LocalDateTime localDate = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
        return localDate.format(FORMATTER_YYYY_MM_DD_HH_MM_SS);
    }

2.@Schema导致Error creating bean with name ‘swaggerFacadeOpenApiProvider’ defined in URL [jar:file:/D:/maven/repo-gscp/com/linewell/gov/hoox/gov-hoox-swagger/1.0.2/gov-hoox-

实际是由于@Schema的 implement属性值赋错了,像List这种就应该给具体的对象类型;
@Schema(name = “handleSysFileList”, title = “诉求处理附件”, description = “诉求处理附件” ,implementation = CmpNonSysFileDto.class)
private List handleSysFileList;

给个三连吧 谢谢谢谢谢谢了
【Java后端】Spring,SpringBoot注解相关问题_第1张图片

你可能感兴趣的:(项目问题解决,spring,spring,boot,java,java-zookeeper,struts,jvm,mybatis)