标签:cli .com ice tor app click framework http pool
注意:这里spring整合struts2,使用的数据库操作类是JdbcTemplate模板,该模板使用c3p0连接池。Spring将JdbcTemplate注册成一个Bean,提供给dao使用【依赖注入】。
spring将扫描包中的所有类,将带有spring的注解【@Controller,@Repository,@Service】的类注册到容器中。
<?xml version="1.0" encoding="UTF-8"?> <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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="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.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://mybatis.org/schema/mybatis-spring"> <!-- 扫描com.getword包下面的java文件,有Spring的相关注解的类,则把这些类注册为Spring的bean --> <context:component-scan base-package="cn.getword"> </context:component-scan> <!-- 1.1加载properties文件 --> <bean id="propertyConfigurer" class="cn.getword.utils.EncryptablePropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:db.properties</value> </list> </property> </bean> <!-- 创建数据源 c3p0--> <bean id="dataSourceId" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="${jdbc.driverClassName}"></property> <property name="jdbcUrl" value="${jdbc.url}"></property> <property name="user" value="${jdbc.username}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!-- 创建模板 ,需要注入数据源--> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSourceId"></property> </bean> </beans>
4.
标签:cli .com ice tor app click framework http pool
原文地址:https://www.cnblogs.com/zhuxiang1633/p/9724707.html