jetty的jndi

jetty的jndi和tomcat的用法

tomcat的jndi是内置的,在web.xml文件里直接默认支持的,所有web项目可以直接使用

<resources>
        <!-- <resource type="jdbc" name="als"      jndiName="jdbc/als" /> -->
        <resource type="jdbc" name="als"      jndiName="java:comp/env/jdbc/als" /> 
    </resources>

但是jetty不同,是默认不支持的,需要配置xml文件去new一个,才可以用

<New id="mydb" class="org.eclipse.jetty.plus.jndi.Resource">  
         <Arg></Arg>  
         <Arg>jdbc/mydb</Arg>  
         <Arg>  
            <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">  
               <Set name="Url">jdbc:mysql://**.**.**.**:3306/***</Set>  
               <Set name="User">****</Set>  
               <Set name="Password">****</Set>  
            </New>  
         </Arg>  
</New>

 

posted @ 2017-09-19 10:44  折翼流萤  阅读(189)  评论(0)    收藏  举报