ssm框架配置文件详解,(分模块配置)

本文详细介绍了SSM框架(Spring、SpringMVC、MyBatis)的配置文件,包括sqlMapConfig.xml、applicationContext-dao.xml、jdbc.properties、log4j.properties、applicationContext-service.xml、applicationContext-trans.xml、Springmvc.xml和web.xml。重点讲解了如何配置数据源、事务管理、日志以及解决SpringMVC拦截静态资源的问题,提供了两种解决方案,一种是在springmvc.xml中添加默认Servlet处理器,另一种是修改web.xml,限制SpringMVC只拦截特定后缀的请求。
摘要由CSDN通过智能技术生成

通过maven创建一个web工程,则经过修改之后会是如下的目录结构:

每个目录的含义我就不一一介绍了,这不是本次讨论的重点,创建好之后,我们在src/main/resources资源目录下加入以下配置文件:

 

一共6个,最后加上一个web.xml的配置,就OK了,现在来详解这些配置文件的内容:

sqlMapConfig.xml

空文件即可:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

</configuration>

 

applicationContext-dao.xml:

需要配置:

加载properties文件,数据源,SqlSessionFactory,Mapper扫描:
 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">

	<!-- 配置 读取properties文件 jdbc.properties -->
	<context:property-placeholder location="classpath:jdbc.properties" />

	<!-- 配置 数据源 -->
	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" /&
  • 6
    点赞
  • 62
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值