<!--tomcat 的server.xml中配置MySQL数据库的JNDI数据源--> <Resource name="mysql_jndi" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="root" password="root" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.1.144:3306/leadtest?useUnicode=true&characterEncoding=utf-8"/>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- 2.使用jndi配置数据库连接池 -->
<bean name="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<!-- 固定格式:java:comp/env/ -->
<!-- 这里写Tomcat服务器中Context节点下的Resource的name属性名 :jdbc_jndi -->
<value>java:comp/env/mysql_jndi</value>
</property>
</bean>
</beans>