对于Maven工程,编译的工作是由Maven程序来完成的,而Maven默认只会把src/main/resources文件夹下的文件拷贝到target/classes文件夹下,.hbm.xml不会被复制到/target/calsses文件夹下,所以Hibernate运行的时候,就会报找不到*.hbm.xml的错误。
解决方法:
在pom.xml中显式地指定Maven把什么资源文件复制到target/classes文件夹下。
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>
原文地址:https://www.cnblogs.com/cloudshining/p/8724103.html
时间: 2024-10-16 03:56:54