配置Tomcat数据源, spring引用


1、spring配置文件配置

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

       xmlns:jee="http://www.springframework.org/schema/jee" 

       xsi:schemaLocation="

       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">


  <!-- Spring 2.0为获取J2EE资源提供了一个jee命名空间,通过jee命名空间,可以有效地简化J2EE资源的引用 -->

  <jee:jndi-lookupid="dbname-dataSource"jndi-name="jdbc/dbname-dataSource" 

       proxy-interface="javax.sql.DataSource"lookup-on-startup="false"/>


2、tomcat的server.xml

<GlobalNamingResources>中添加:

 <Resourceauth="Container"driverClassName="com.mysql.jdbc.Driver"maxActive="100"maxIdle="20"maxWait="10000"name=“jdbc/dbname-dataSource"password=""type="javax.sql.DataSource"url="jdbc:mysql://localhost:3306/dbname?characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull"username="root"/> 


   

3、tomcat的context.xml

<context>中添加:

<ResourceLinkglobal="jdbc/dbname-dataSource"name=“jdbc/dbname-dataSource"type="javax.sql.DataSource"/>



展开阅读全文

没有更多推荐了,返回首页