Jelajahi Sumber

mybatis配置提到common中

shuzheng 9 tahun lalu
induk
melakukan
ccb869f61e

+ 2 - 2
cms/cms-service/src/main/java/com/zheng/cms/dao/mapper/UserVOMapper.xml

@@ -6,7 +6,7 @@
 	<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
 	<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
 	
 	
 	<!-- 结果映射关系 -->
 	<!-- 结果映射关系 -->
-	<resultMap id="UserResultMap" type="userVO">
+	<resultMap id="UserResultMap" type="com.zheng.cms.dao.model.UserVO">
 		<id column="u_id" property="id"/>
 		<id column="u_id" property="id"/>
 		<result column="username" property="username"/>
 		<result column="username" property="username"/>
 		<result column="password" property="password"/>
 		<result column="password" property="password"/>
@@ -14,7 +14,7 @@
 		<result column="sex" property="sex"/>
 		<result column="sex" property="sex"/>
 		<result column="ctime" property="ctime"/>
 		<result column="ctime" property="ctime"/>
 		<result column="content" property="content" />
 		<result column="content" property="content" />
-		<collection column="userid" property="books" ofType="Book">
+		<collection column="userid" property="books" ofType="com.zheng.cms.dao.model.Book">
 			<id column="b_id" property="id"/>
 			<id column="b_id" property="id"/>
 			<result column="userid" property="userid"/>
 			<result column="userid" property="userid"/>
 			<result column="name" property="name"/>
 			<result column="name" property="name"/>

+ 0 - 1
cms/cms-service/src/main/java/com/zheng/cms/dao/model/UserVO.java

@@ -1,6 +1,5 @@
 package com.zheng.cms.dao.model;
 package com.zheng.cms.dao.model;
 
 
-import java.awt.print.Book;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**

+ 3 - 3
cms/cms-dao/src/main/resources/applicationContext-jdbc.xml → common/src/main/resources/applicationContext-jdbc.xml

@@ -34,7 +34,7 @@
 		<property name="timeBetweenEvictionRunsMillis" value="60000" />
 		<property name="timeBetweenEvictionRunsMillis" value="60000" />
 		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
 		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
 		<property name="minEvictableIdleTimeMillis" value="300000" />
 		<property name="minEvictableIdleTimeMillis" value="300000" />
-		<!--  -->
+		<!-- 校验语句 -->
 		<property name="validationQuery" value="SELECT 1" />
 		<property name="validationQuery" value="SELECT 1" />
 		<property name="testWhileIdle" value="true" />
 		<property name="testWhileIdle" value="true" />
 		<property name="testOnBorrow" value="false" />
 		<property name="testOnBorrow" value="false" />
@@ -47,11 +47,11 @@
 	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
 	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
 		<property name="dataSource" ref="dataSource" />
 		<property name="dataSource" ref="dataSource" />
 		<property name="configLocation" value="classpath:mybatis-config.xml" />
 		<property name="configLocation" value="classpath:mybatis-config.xml" />
-		<property name="mapperLocations" value="classpath:com/zheng/cms/dao/mapper/*Mapper.xml" />
+		<property name="mapperLocations" value="classpath*:**/mapper/*Mapper.xml" />
 	</bean>
 	</bean>
 	<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
 	<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
 	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
 	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
-		<property name="basePackage" value="com.zheng.cms.dao.mapper" />
+		<property name="basePackage" value="**.mapper" />
 		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
 		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
 	</bean>
 	</bean>
 
 

+ 2 - 0
cms/cms-dao/src/main/resources/mybatis-config.xml → common/src/main/resources/mybatis-config.xml

@@ -10,8 +10,10 @@
 	</settings>
 	</settings>
 
 
 	<!-- 该包下的model不用写包名,会使用 model的首字母小写的非限定类名来作为它的别名,若有注解@Alias("xxx"),则别名为注解值 -->
 	<!-- 该包下的model不用写包名,会使用 model的首字母小写的非限定类名来作为它的别名,若有注解@Alias("xxx"),则别名为注解值 -->
+	<!--
 	<typeAliases>
 	<typeAliases>
 		<package name="com.zheng.cms.dao.model" />
 		<package name="com.zheng.cms.dao.model" />
 	</typeAliases>
 	</typeAliases>
+	-->
 
 
 </configuration>
 </configuration>