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>

浙公网安备 33010602011771号