<!-- 配置c3po数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<!-- 注入属性值 -->
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql:///text"></property>
<property name="user" value="root"></property>
<property name="password" value="123456"></property>
</bean>
<!-- 配置sqlSessionFactory(整合包中) -->
<bean id="sqlSessionFactory" class=" org.mybatis.spring.SqlSessionFactoryBean">
<!-- 加载mabites配置文件 -->
<property name="configLocation" value="classpath:SqlMapConfig.xml"></property>
<!-- 引入数据源 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 通过MapperFactoryBean创建代理对象 -->
<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.cs.mapper.UserMapper"></property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>
<!-- 组件扫描 -->
<context:component-scan base-package="com.cs"></context:component-scan>
<!-- 配置视图解析器 -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<mvc:annotation-driven/>
<!-- 配置拦截器 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.cs.filter.StringmvcFilter"></bean>
</mvc:interceptor>
</mvc:interceptors>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
SSM--之springMVC配置文件综合
最新推荐文章于 2023-03-21 11:25:28 发布