<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	   xmlns:context="http://www.springframework.org/schema/context"
	   xmlns:mvc="http://www.springframework.org/schema/mvc"
	   xmlns:task="http://www.springframework.org/schema/task" xmlns:tx="http://www.springframework.org/schema/tx"
	   xmlns:util="http://www.springframework.org/schema/util"
	   xsi:schemaLocation="http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


	<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:datasource.properties</value>
			</list>
		</property>
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.ag.devbusiness"/>
	</bean>

	<bean id="mybatisConfig" class="com.baomidou.mybatisplus.core.MybatisConfiguration">
		<property name="mapUnderscoreToCamelCase" value="true"/>
		<property name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl"></property>
		<!-- 部分数据库不识别默认的NULL类型（比如oracle，需要配置该属性 -->
		<property name="jdbcTypeForNull">
			<util:constant static-field="org.apache.ibatis.type.JdbcType.NULL"/>
		</property>
	</bean>


	<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="configuration" ref="mybatisConfig"/> <!--  非必须  -->
		<property name="globalConfig" ref="globalConfig"/> <!--  非必须  -->
		<property name="mapperLocations">
			<list>
				<value>classpath:agCommon/*.xml</value>
				<value>classpath:permission/*Mapper.xml</value>
			</list>
		</property>
	</bean>


	<bean id="globalConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
		<property name="dbConfig" ref="dbConfig"/> <!--  非必须  -->
	</bean>

	<bean id="dbConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig.DbConfig">
		<!--主键生成策略-->
		<property name="idType" value="UUID"/>
	</bean>
	<!-- 装配数据源 -->
	<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource">
		<!--<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
		<property name="jdbcUrl" value="jdbc:oracle:thin:@122.5.19.222:61521:oracl"/>
		<property name="username" value="AG_QHD_IMTOS"/>
		<property name="password" value="AGSOFT"/>-->
		<property name="driverClassName" value="${jdbc.driverClassName}"/>
		<property name="jdbcUrl" value="${main.url}" />
		<property name="username" value="${main.username}" />
		<property name="password" value="${main.password}" />

		<!-- 等待连接池分配连接的最大时长（毫秒），超过这个时长还没可用的连接则发生SQLException， 缺省:30秒
		<property name="connectionTimeout" value="30" />-->
		<!-- 一个连接idle状态的最大时长（毫秒），超时则被释放（retired），缺省:10分钟 -->
		<property name="idleTimeout" value="10" />
		<!-- 一个连接的生命时长（毫秒），超时而且没被使用则被释放（retired），缺省:30分钟，建议设置比数据库超时时长少30秒，参考MySQL wait_timeout参数（show variables like '%timeout%';）
		<property name="maxLifetime" value="${maxLifetime}" /> -->
		<!-- 连接池中允许的最大连接数。缺省值：10；推荐的公式：((core_count * 2) + effective_spindle_count) -->
		<property name="maximumPoolSize" value="20" />
		<!--<property name="dataSourceProperties">
			<props>
				<prop key="remarksReporting">true</prop>
			</props>
		</property>-->
	</bean>

	<bean id="jdbcTemplatebusiness"
		  class="org.springframework.jdbc.core.JdbcTemplate" abstract="false"
		  lazy-init="false" autowire="default">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
	</bean>
	<bean id="feeJdbcTemplate"
		  class="org.springframework.jdbc.core.JdbcTemplate" abstract="false"
		  lazy-init="false" autowire="default">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
	</bean>

</beans>