Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml

Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第1张图片

原因是gradle编译时,只复制java文件夹下的.java文件,忽略了XXX.hbm.xml文件,导致在编译输出目录找不到,(当自己手动复制下就解决了):

Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第2张图片
Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第3张图片
Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第4张图片

解决办法:在build.gradle里面添加代码,复制所有的.xml文件到输出目录:

task xmlCopy(type: Copy) {

    copy {

        from("src/main/java") {

            include ("**/*.xml")

        }

        into("${rootDir}/out/production/classes")

    }

}


Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第5张图片

解决:


Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml_第6张图片

你可能感兴趣的:(Caused by: org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found :xxx.hbm.xml)