<!-- JNDI的配置方式 
tomcatJNDI:java:comp/env/jdbc/xaws
weblogic/was
JNDI:jdbc/xaws <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/xaws"/>
</bean>
-->
<!-- tomcatJNDI
<property name="jndiName" value="java:comp/env/jdbc/xaws"/>
-->

重要的是红色的话语 在spring的数据库配置文件中写入

web.xml的配置

<!-- JNDI 
<resource-ref>
<res-ref-name>jdbc/xaws</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>-->