spring applicationContext.xml文件中 引用db.properties 文件,找不到对应属性

我在springMVC项目中,applicationContext.xml文件中配置dataSource 的bean ,想要引用上面的db.properties文件里面配置的内容,但是报错:

控制台内容:

 Converted JNDI name [java:comp/env/jdbc.driver] not found - trying original name [jdbc.driver]. javax.naming.NameNotFoundException: 名称[jdbc.driver]未在此上下文中绑定。找不到[jdbc.driver]。
DEBUG [localhost-startStop-1] - Looking up JNDI object with name [jdbc.driver]
DEBUG [localhost-startStop-1] - JNDI lookup for name [jdbc.driver] threw NamingException with message: 名称[jdbc.driver]未在此上下文中绑定。找不到[jdbc.driver]。. Returning null.
DEBUG [localhost-startStop-1] - Found key 'jdbc.driver' in PropertySource 'localProperties' with value of type String
DEBUG [localhost-startStop-1] - Looking up JNDI object with name [java:comp/env/jdbc.url]
DEBUG [localhost-startStop-1] - Converted JNDI name [java:comp/env/jdbc.url] not found - trying original name [jdbc.url]. javax.naming.NameNotFoundException: 名称[jdbc.url]未在此上下文中绑定。找不到[jdbc.url]。
DEBUG [localhost-startStop-1] - Looking up JNDI object with name [jdbc.url]
DEBUG [localhost-startStop-1] - JNDI lookup for name [jdbc.url] threw NamingException with message: 名称[jdbc.url]未在此上下文中绑定。找不到[jdbc.url]。. Returning null.
DEBUG [localhost-startStop-1] - Found key 'jdbc.url' in PropertySource 'localProperties' with value of type String

applicatioContext.xml内容:

image.png

db.properties 内容:

image.png

阅读 2.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题