properties找不到 java_Spring通过classpath找不到jdbc.properties

报错:class path resource [src/main/resources/jdbc.properties] cannot be opened because it does not exist()//xml中关于资源文件部分

e0cd1de318ba7cdc825cead5561886d9.png

jdbc.properties和spring-resouce.xml  我都放在resouces这个目录下面,已经make as resource了

但是执行的时候就报错

class path resource [src/main/resources/jdbc.properties] cannot be opened because it does not exist

然后我把这两个文件全部放在源码目录就可以了(当然要写绝对路径)

从报错上看就是class path就是这个resource,怎么会找不到文件?

我的test目录下的test resource都是能正常使用的,为什么main下的就不可以

如果我单独只把jdbc.properties放在main目录下java下的包中,spring-resouce这个还是放在resource当中(这个时候spring-resouce中

class path resource [src/main/resources/jdbc.properties] cannot be opened because it does not exist

一定要2个都改才可以

最新的结果是,我把这个xml和properties直接都扔到test的resources中就可以了

有一点眉目了,我在测试类中加载的xml是放在测试类的resources中的,而源码的xml是放在main下的resources中,看起来不能同时使用这两个

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值