主要分为三个部分进行配置,以免过于混乱
1. applicationContext-dao.xml <!-- 数据访问层配置 -->
主要配置数据源DataSource以及需要的sessionFactory
2. applicationContext-service.xml <!--服务层配置 -->
主要针对service层配置事务管理transationManager,aop,事务的传播行为以及文件上传配置
3. applicationContext-servlet.xml
开启注解支持<mvc:annotation-driven />
开启注解扫描<context:component-scan base-package="">
拦截器<mvc:interceptors>
静态资源访问配置<mvc:resources mapping="/resources/**" location="/resources/" />
视图解析器
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
4.applicationContext.xml
<!-- 数据访问层配置 -->
<import resource="classpath:spring/applicationContext-dao.xml" />
<!--服务层配置 -->
<import resource="classpath:spring/applicationContext-service.xml" />
关于Spring配置文件
最新推荐文章于 2023-11-15 18:31:28 发布