Could not open ServletContext resource

Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/syg.properties]
        at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:159)
        at org.springframework.core.io.support.EncodedResource.getReader(EncodedResource.java:143)
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:95)
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:73)
        at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:59)
        at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:67)
        at org.springframework.core.io.support.DefaultPropertySourceFactory.createPropertySource(DefaultPropertySourceFactory.java:37)
        at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:462)
        at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:279)
        at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198)
        at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:303)
        at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:249)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:206)
        at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:174)
        ... 26 more

此类问题我们将其归类为配置文件找不到,不管是maven项目,gradle项目,亦或是普通web项目,不管是.properties或者.xml,都是路径问题。
既然是路径问题,通常有三种
1,常用tomcat等容器的默认路径:[不同容器有不同,根据具体使用的容器查找即可]
2,类路径:[class文件所在的位置]
3,自定义路径:[多数会编译到类路径中]

此问题:Could not open \color{red}{ServletContext} resource ,其实重点就是ServletContext,说明是在容器默认路径没找到,因为我们的项目是自定义路径,所以修改一下配置的路径就ok了。
中间涉及到的框架和具体细节没有展开讲,如果需要沟通请添加微信公众号留言:不清不楚的迷茫

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容