本章内容在第三章《Java框架整合--企业中的项目架构以及多环境分配》的代码上做修改,链接如下:http://www.cnblogs.com/java-zhao/p/5115136.html1、实现方式将之前ssmm0-userManagement中类路径(src/main/re ...
本章内容在第三章《Java框架整合--企业中的项目架构以及多环境分配》的代码上做修改,链接如下:
http://www.cnblogs.com/java-zhao/p/5115136.html
1、实现方式
将之前ssmm0-userManagement中类路径(src/main/resources)下的spring.
切分前的spring.
<??><beans ="http://www.springframework.org/schema/beans" ="http://www.w3.org/2001/ ="http://www.springframework.org/schema/context" ="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"> <!-- 注解扫描 --> <context:component-scan base-package="com.xxx" /> <!-- 配置fastjson转换器 --> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"></bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 引入数据源,这里变量的读取都是从ssmm0的pom.--> <bean id="xxxDataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <!-- 引入mybatis --> <bean id="xxxSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="xxxDataSource" /> </bean> <bean id="xxxMapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!-- 这里就是包名为什么就做com.xxx.mapper.user而非com.xxx.user.mapper, 这样的话,比如说有两个项目com.xxx.mapper.user和com.xxx.mapper.hotel,value只需写作com.xxx.mapper即可 否则,value就要写作com.xxx.user.mapper,com.xxx.hotel.mapper --> <property name="basePackage" value="com.xxx.mapper" /> <property name="sqlSessionFactoryBeanName" value="xxxSqlSessionFactory" /> </bean> <!-- 配置velocity --> <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"> <property name="resourceLoaderPath"> <value>WEB-INF/templates/</value> </property> <property name="velocityProperties"> <props> <prop key="input.encoding">UTF-8</prop> <prop key="output.encoding">UTF-8</prop> </props> </property> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"> <property name="suffix" value=".vm" /> <property name="contentType" value="text/html;charset=utf-8" /> <property name="dateToolAttribute" value="date"/> <property name="numberToolAttribute" value="number"/> </bean></beans>
原标题:第四章 Java框架整合
关键词:JAVA
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。