druid在spring中的配置已经maven中的配置



        <dependency>
	    <groupId>com.alibaba</groupId>
	    <artifactId>druid</artifactId>
	    <version>1.0.18</version>
	</dependency>
	<dependency>
	    <groupId>org.wisdom-framework</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.34_1</version>
	</dependency>
        <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>${version.spring-framework}</version>
	</dependency>

这里不用mysql中,是因为mysl中的mysql-connector-java要出问题

spring.xml文件


<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:p="http://www.springframework.org/schema/p"  
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:task="http://www.springframework.org/schema/task" 
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
	       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd
           http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
           http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd"
           default-autowire="byName">

	<bean id="app" class="com.nb.store.App"></bean>
	<bean id="javaMailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"  
       p:host="10.xx.xx.xx" 
       p:username="xxxxxxx" 
       p:password="xxxxxxxxx"/> 
     
    <bean id="simpleMailMessage" class="org.springframework.mail.SimpleMailMessage" 
       p:from="noreply@nubia.cn"/>
    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
    	<property name="resourceLoaderPath" value="/" />
		<property name="velocityProperties">
		<props>
		<prop key="input.encoding">UTF-8</prop>
		<prop key="output.encoding">UTF-8</prop>
		<prop key="default.contentType">text/html; charset=UTF-8</prop>
		</props>
		</property>
    </bean>
    <context:property-placeholder location="classpath:xxxxx"/>  这里注意,如果没有xxxx文件,会报错
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> 
	    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
	    <property name="url" value="jdbc:mysql://127.0.0.1:3306/test?zeroDateTimeBehavior=convertToNull&autoReconnect=true&useUnicode=true&characterEncoding=utf-8" />
	    <property name="username" value="root" />
	    <property name="password" value="root" />
	     
	    <property name="filters" value="stat" />
	 
	    <property name="maxActive" value="20" />
	    <property name="initialSize" value="1" />
	    <property name="maxWait" value="60000" />
	    <property name="minIdle" value="1" />
	 
	    <property name="timeBetweenEvictionRunsMillis" value="60000" />
	    <property name="minEvictableIdleTimeMillis" value="300000" />
	 
	    <property name="validationQuery" value="SELECT 'x'" />
	    <property name="testWhileIdle" value="true" />
	    <property name="testOnBorrow" value="false" />
	    <property name="testOnReturn" value="false" />
	     
	    <property name="poolPreparedStatements" value="true" />
	    <property name="maxPoolPreparedStatementPerConnectionSize" value="50" />
	</bean>
	<!--JDBC模板定义 -->
	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="dataSource"/>
	</bean>
</beans>



 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值