javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

很久没写web项目,结果出现如上错误,原因是在context.xml配置数据源后,没有在web.xml里添加引用。context.xml里的配置是:
<Resource name= "jdbc/security" auth= "Container" type= "javax.sql.DataSource" maxActive= "100" maxIdle= "30" maxWait= "10000"
                username= "test" password= "test" driverClassName= "com.mysql.jdbc.Driver" url= "jdbc:mysql://127.0.0.1:3306/test" />
web.xml需要加上:
    <resource-ref>
            <description>My DataSource Reference</description>
            <res-ref-name>jdbc/security</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

你可能感兴趣的:(jdbc,Security,数据源,是)