标签:.sql manage servlet ace eal location code nal date
spring配置文件的配置
<!-- 注解包扫描 --> <context:component-scan base-package="com.tx"/> <!-- 读取数据库配置文件 --> <context:property-placeholder location="classpath:db.properties"/> <!-- 配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClass}"></property> <property name="url" value="${jdbc.url}"></property> <property name="username" value="${jdbc.user}"></property> <property name="password" value="${jdbc.password}"></property> </bean> <!-- 配置mybatis的sessionfactory --> <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <!-- 读取mybatis配置文件 --> <property name="configLocation" value="classpath:sqlMapConfig.xml"></property> </bean> <!-- mapper动态代理开发,扫描dao包 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" > <property name="basePackage" value="com.tx.dao"></property> </bean> <!-- 配置事务 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="select*" read-only="true"/> </tx:attributes> </tx:advice> <aop:config> <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.tx.service..*.*(..))"/> </aop:config>
Mybatis配置文件
1 <?xml version="1.0" encoding="UTF-8" ?> 2 <!DOCTYPE configuration 3 PUBLIC "-//mybatis.org//DTD Config 3.0//EN" 4 "http://mybatis.org/dtd/mybatis-3-config.dtd"> 5 <configuration> 6 <!-- 自定义匿名 --> 7 <typeAliases> 8 <package name="com.tx.model"/> 9 </typeAliases> 10 11 12 <mappers> 13 <mapper resource="com/tx/mapper/PersonMapper.xml"/> 14 <mapper resource="com/tx/mapper/OrdersMapper.xml"/> 15 </mappers> 16 </configuration>
SpringMVC配置文件
1 <!-- controller的扫描包 --> 2 <context:component-scan base-package="com.tx.controller"></context:component-scan> 3 <!-- 视图解析 --> 4 <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 5 <property name="prefix" value="/WEB-INF/jsp/"></property> 6 <property name="suffix" value=".jsp"></property> 7 </bean> 8 <!-- 注解驱动 --> 9 <mvc:annotation-driven />
标签:.sql manage servlet ace eal location code nal date
原文地址:https://www.cnblogs.com/cat-fish6/p/9994270.html