class path resource [quartz.properties] cannot be opened because it does not exist

从公司 SVN上更新了代码之后,运行一个spring boot项目,死活不能成功。以前可以。错误很多很吓人,但干货是这一句:

class path resource [quartz.properties] cannot be opened because it does not exist

从错误提示来看,很明显,说找不到配置文件“quartz.properties”,但明明就是有的啊。

在这里插入图片描述

	// 指定quartz.properties,可在配置文件中配置相关属性
	@Bean
	public Properties quartzProperties() throws IOException {
		PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
		propertiesFactoryBean.setLocation(new ClassPathResource("/config/quartz.properties"));
		propertiesFactoryBean.afterPropertiesSet();
		return propertiesFactoryBean.getObject();
	}

我目前为止,还是个JAVA白痴,于是又开始了寻寻觅觅的瞎琢磨过程。最后发现,代码没有问题,原因是编译结果里,没有将这个配置文件带过去。也就是,存放编译结果所在的文件夹target里,不知道为什么没有将这个配置文件拷贝过去。原来,提示找不到文件,不是看你代码里有没有,真正要看的,是编译结果啊。

在这里插入图片描述
解决办法:
将项目rebuild一次,再运行,就正常了。原因我估计是不知道为什么,这个文件可能被占用了,之前的运行过程中,一直拷贝失败。

发布了1105 篇原创文章 · 获赞 337 · 访问量 338万+

猜你喜欢

转载自blog.csdn.net/leftfist/article/details/102896194
今日推荐