首先检查一下路径问题,servlet看一下web.xml里面是否有配置或是否添加了注解。
若都没有问题,看一下tomcat的启动信息,查看是否有报错提示。若出现以下提示或相似提示:
Could not open ServletContext resource [/db.properties]
去spring的applicationContext.xml里面看一下,配置读取外部properties文件的路径是否有写错:
<context:property-placeholder location="db.properties" />
改成
<context:property-placeholder location="classpath:db.properties" />
然后再试一下,应该就可以解决问题了。点赞下次不迷路。