创建spring配置
生活随笔
收集整理的這篇文章主要介紹了
创建spring配置
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<!--開啟注解掃描-->
<context:component-scan base-package="com.leon.service"><context:exclude-filter type="aspectj" expression="com.leon.controller..*"/>
</context:component-scan><!-- 創(chuàng)建DataSource-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver"/><property name="url" value="jdbc:mysql://localhost:3306/ssm?characterEncoding=UTF-8"/><property name="username" value="root"/><property name="password" value="root"/>
</bean><!-- 創(chuàng)建 SQLSessionFactoryBean -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="mapperLocations" value="classpath:com/leon/mapper/*.xml"/><property name="typeAliasesPackage" value="com.leon.entity"/>
</bean><!-- 創(chuàng)建dao -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/><property name="basePackage" value="com.leon.dao"/>
</bean><!-- 創(chuàng)建事務(wù)管理器-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/>
</bean><!-- 開啟注解事務(wù)生效-->
<tx:annotation-driven transaction-manager="transactionManager"/>
總結(jié)
以上是生活随笔為你收集整理的创建spring配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis集群细节
- 下一篇: springboot项目中日志分类