Embed hibernate hbm.xml mappings in jar

前端 未结 5 1047
耶瑟儿~
耶瑟儿~ 2020-12-20 00:06

Is it possible to embed the hibernate mapping hbm.xml’s to the jar and avoid manual reference in applicationContext.xml like

  

        
5条回答
  •  醉梦人生
    2020-12-20 00:37

    Yes, you can, by default Spring goes from the class path when search for mapping files. So if the jar is on your class path, it should find the files no problem for the hibernate mapping files to be included in your local session factory bean.

    So if your mapping file is in my.spring.package and is called mapping.xml, the path

    my/spring/package/mapping.xml
    

    should work just fine.

    EDIT

    Thanks for the comment, I will update my answer.

    NO, you cannot point at a jar... but YES, you may point to mapping files in the jar.

提交回复
热议问题