1.配置Tomcat数据源
修改tomcat安装目录/conf/context.xml,添加如下配置
<Resource
name="jdbc/DataSource"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
url="jdbc:mysql://localhost:3306/erpdb"
driverClassName="com.mysql.jdbc.Driver"
username="root"
password="root"
/>2.配置Web应用使用Tomcat数据源
修改WEB/INF/web.xml,添加如下配置
<resource-ref>
<res-ref-name>jdbc/DataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>3.配置Spring核心配置文件中使用数据源
开启jee命名空间
xmlns:jee="http://www.springframework.org/schema/jee"
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
使用jee命名空间<jee:indi-lookup id="dataSource"
jndi-name="java:comp/env/jdbc/dataSource"
4. 重启服务器,测试功能
测试通过,可以正常登陆
1171

被折叠的 条评论
为什么被折叠?



