在SpringBoot项目上使用DBUNIT运行Junit测试时出错

问题描述

我有一个Junit测试,在运行它时出现此错误

org.dbunit.dataset.NoSuchColumnException: AUTORISATION_BONANZA.ORGANISATION_ID -  (Non-uppercase input column: ORGANISATION_ID) in ColumnNametoIndexes cache map. Note that the map's column names are NOT case sensitive.

实体

@Entity
@NoArgsConstructor
@Data
public class AutorisationBonanza implements Serializable {

    @Id
    @Column(name = "AUTORISATION_BONANZA_ID")
    private Long autorisationBonanzaId;
    private String pol;
    private String nomom;


    @ManyToOne
    @JoinColumn(name = "ORGANISATION_ID")
    private Organisation organisation;


}

数据集:

<AUTORISATION_BONANZA
        AUTORISATION_BONANZA_ID="1"
        POL="NOM"
        NOMOM="PRENOM"
        ORGANISATION_ID="1"
        />

@Entity
@NoArgsConstructor
@Data
public class Organisation implements Serializable {

    @Id
    @Column(name = "ORGANISATION_ID")
    private Long organisationId;
    private String code;



}

解决方法

尝试将其添加到属性文件中:

org.dbunit.database.IMetadataHandler.implClassName=org.dbunit.ext.mysql.MySqlMetadataHandler