在tomcat中發布web項目,可能是因為spring中配置了jndi(只配置了jndi,其他的有工具包封裝了)。
啟動的時候報錯(在項目目錄下,在tomcat中配置context指向項目目錄就沒問題,打包發布到
tomcat就報錯了),拋的異常是:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

在web.xml中添加配置如下:
<resource-ref>
  <description>DB Connection</description>
  <res-ref-name>jdbc/test</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>