1.tomcat下先配置context.xml
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"maxActive="100"
maxIdle="30"
maxWait="10000"
name="bookshare"
username="***"
password="**"
type="javax.sql.DataSource" url="jdbc:mysql://ip:端口/bookshare?useUnicode=true&characterEncoding=UTF-8" />
2.在config.properties
jndiName = java:comp/env/bookshare
3.在db.xml
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jndiName}">
</property>
</bean>
<context:property-placeholder location="WEB-INF/config.properties" />//装配config.properties文件到db.xml文件里