java Name [jdbc/myjavadb] is not bound in this Context. Unable to find [jdbc].

1、出錯時的狀況:java

首先,這是一個servlet項目mysql

1.項目的web.xml配置了:(後來發現不配置這個也行,可是tomcat必定要配置)web

  <resource-ref>
   <description>DB Connection</description>
   <res-ref-name>jdbc/myjavadb</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
 </resource-ref>

 

2.tomcat的xml也配置了,在conf\Catalina\localhost下配置了 "項目名稱.xml"文件,文件內容:sql

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/webdemo" docBase="webdemo" debug="0"> 
 <Resource name="jdbc/myjavadb" auth="Container"
              type="javax.sql.DataSource"
             
              driverClassName="com.mysql.jdbc.Driver"
             
              url="jdbc:mysql://localhost:3306/myjavadb"
              
              username="root"
               
              password="1234"
               
              maxActive="200"
               
              maxIdle="50"
               
              maxWait="3000"
              
                />
</Context>
View Code

2、分析(瞎貓遇見死耗子)發現:tomcat

tomcat的conf\context.xml不知道何時被我配置了一句:ide

<ResourceLink global="jdbc/myjavadb" name="jdbc/myjavadb" type="javax.sql.DataSource"/>  

刪掉這句,保存,運行項目,OKurl

相關文章
相關標籤/搜索