spring整合struts2
2021-06-16 19:03
标签:cli .com ice tor app click framework http pool 注意:这里spring整合struts2,使用的数据库操作类是JdbcTemplate模板,该模板使用c3p0连接池。Spring将JdbcTemplate注册成一个Bean,提供给dao使用【依赖注入】。 spring将扫描包中的所有类,将带有spring的注解【@Controller,@Repository,@Service】的类注册到容器中。 4. spring整合struts2 标签:cli .com ice tor app click framework http pool 原文地址:https://www.cnblogs.com/zhuxiang1633/p/9724707.html1.jar包
2. 配置web.xml
3.applicationContext.xml
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">
context:component-scan base-package="cn.getword">
context:component-scan>
bean id="propertyConfigurer"
class="cn.getword.utils.EncryptablePropertyPlaceholderConfigurer">
property name="locations">
list>
value>classpath:db.propertiesvalue>
list>
property>
bean>
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>