ClassPathXmlApplicationContext无法加载XML

来源:互联网 发布:虚拟主机 域名 编辑:程序博客网 时间:2024/05/17 21:48

原因:ClassPathXmlApplicationContext 只能加载classes下的XML文件

解决方法:把存在XML的文件夹加入到 classpath  or resources

链接参见:http://stackoverflow.com/questions/3765998/add-a-properties-file-to-intellijs-classpath

方法一:设置pom

<build>  ...  <resources>    <resource>      <directory>src/main/resources</directory>    </resource>  </resources>  ...</build>
方法二:在IDE里设置


我因为写在test里了,所以设置的Test Sources

0 0
原创粉丝点击