你查看springboot的源码,有很多类都有这个文件,在idea不能创建,因为不支持这种命名,只能用记事本创建后复制都项目中。
主要应用是给类添加正常,或者把公用的注解都放到这里,常量不合适,作用范围这有当前包下
没有引用前
每个对象要引用json对象字段,都需要添添加上面的注解,
@TypeDefs({@TypeDef(name = "json", typeClass = JsonType.class),@TypeDef(name = "string-array", typeClass = StringArrayType.class),@TypeDef(name = "long-array", typeClass = LongArrayType.class) }) @Entity @Table(name = "party_build_task") public class PartyBuildTask implements Serializable {@Id@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")@SequenceGenerator(name = "sequenceGenerator")private Long id;@Type(type = "json")@Column(columnDefinition = "jsonb", name = "filter_list")private List<FilterListVO> filterList;
}
引用后
package-info.java内容是
@TypeDefs({@TypeDef(name = "json", typeClass = JsonType.class),@TypeDef(name = "string-array", typeClass = StringArrayType.class),@TypeDef(name = "long-array", typeClass = LongArrayType.class) }) package cn.geoway.h2bmf.domain;import com.vladmihalcea.hibernate.type.array.LongArrayType; import com.vladmihalcea.hibernate.type.array.StringArrayType; import com.vladmihalcea.hibernate.type.json.JsonType; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs;