package gg;
public class hj {
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:context=\"http://www.springframework.org/schema/context\" xmlns:tx=\"http://www.springframework.org/schema/tx\"
xmlns:aop=\"http://www.springframework.org/schema/aop\"
xsi:schemaLocation=\"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
\">
<!--自动扫描-->
/context:component-scan
<context:property-placeholder ignore-unresolvable=\"true\" location=\"classpath:jdbc.properties\"/>
<!--============================配置数据源=================================-->
<bean id=\"dataSource\" class=\"com.alibaba.druid.pool.DruidDataSource\" init-method=\"init\"
destroy-method=\"close\">
<property name=\"driverClassName\" value=\"${driverClass}\"/>
<property name=\"url\" value=\"${jdbcurl}\"/>
<property name=\"username\" value=\"${jdbcusername}\"/>
<property name=\"password\" value=\"${jdbcpassword}\"/>
<!-- 初始化连接大小 -->
<property name=\"initialSize\" value=\"2\"/>
<!-- 连接池最大使用连接数量 -->
<property name=\"maxActive\" value=\"${maxActive}\"/>
<!-- 连接池最大空闲 -->
<!-- <property name=\"maxIdle\" value=\"20\" /> -->
<!-- 连接池最小空闲 -->
<property name=\"minIdle\" value=\"${minIdle}\"/>
<!-- 获取连接最大等待时间 -->
<property name=\"maxWait\" value=\"${maxWait}\"/>
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name=\"timeBetweenEvictionRunsMillis\" value=\"60000\"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name=\"minEvictableIdleTimeMillis\" value=\"25200000\"/>
<!-- 打开removeAbandoned功能 -->
<property name=\"removeAbandoned\" value=\"true\"/>
<!-- 1800秒,也就是30分钟 -->
<property name=\"removeAbandonedTimeout\" value=\"1800\"/>
<!-- 关闭abanded连接时输出错误日志 -->
<property name=\"logAbandoned\" value=\"true\"/>
<!-- 监控数据库 -->
<!-- <property name=\"filters\" value=\"stat\" /> -->
<property name=\"filters\" value=\"mergeStat\"/>
</bean>
<!-- mybatis和spring完美整合,不需要mybatis的配置映射文件 -->
<bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\">
<property name=\"dataSource\" ref=\"dataSource\"/>
<!-- 自动扫描mapping.xml文件 -->
<property name=\"mapperLocations\" value=\"classpath:/mapper/*.xml\"/>
<!-- 分页查询(mybatis 3.2.8以上版本)-张晗 -->
<property name=\"plugins\">
<array>
<bean class=\"com.github.pagehelper.PageInterceptor\">
<property name=\"properties\">
<value>
helperDialect=mysql
</value>
</property>
</bean>
</array>
</property>
</bean>
<!--DAO接口所在包名,Spring会自动查找其下的类-->
<bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\">
<!--制定扫描的包名扫描dao层下的类-->
<property name=\"basePackage\" value=\"com.books.dao\"/>
<property name=\"sqlSessionFactoryBeanName\" value=\"sqlSessionFactory\"/>
</bean>
<!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
<bean id=\"transactionManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\">
<property name=\"dataSource\" ref=\"dataSource\"/>
</bean>
<!--使用注释事务 -->
<tx:annotation-driven transaction-manager=\"transactionManager\"/>
<!-- <import resource=\"spring-schedule.xml\"/> -->
</beans>
15-Mar-2018 16:01:27.914 严重 [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.