使用eclipse搭建SSM框架开发环境(不需要在eclipse中插入插件)

什么是SSM

SSM(Spring+SpringMVC+MyBatis)框架集由Spring、MyBatis两个开源框架整合而成(SpringMVC是Spring中的部分内容)。常作为数据源较简单的web项目的框架。(摘自百度百科)
百度百科——SSM

applicationContext.xml文件,注意要根据自己的项目修改文件中的路径
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xmlns:aop="http://www.springframework.org/schema/aop"
		xmlns:context="http://www.springframework.org/schema/context"
		xmlns:tx="http://www.springframework.org/schema/tx"
		xsi:schemaLocation="
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

	<!-- 加载数据库连接的配置文件 -->
	<context:property-placeholder location="classpath:com/ddw/config/jdbc.properties"/>
	
	<!-- 创建数据源,使用的是dbcp -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="${driver}"></property>
		<property name="url" value="${url}"></property>
		<property name="username" value="${name}"></property>
		<property name="password" value="${password}"></property>
	</bean>
	
	<!-- 创建sqlSession工厂 -->
	<!--  id="sqlSessionFactory" -->
	<bean class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 注入数据源 -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- 加载映射文件 -->
		<property name="mapperLocations">
			<list>
				<value>classpath:com/ddw/dao/*Mapper.xml</value>
			</list>
		</property>
		<!-- entity包下所有类,起别名
		com.rj182.entity.User ==> User -->
		<property name="typeAliasesPackage" value="com.ddw.entity"></property>
	</bean>
	
	<!-- 使用IOC实现Dao层的动态代理 -->
	<!-- sqlSession.getMapper(UserDao.class)
	名字:UserDao ==> userDao -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 在这个包下所有接口由spring动态生成代理对象 -->
		<property name="basePackage" value="com.ddw.dao"></property>
	</bean>
	
	
	<!-- 开启注解扫描 -->
	<context:component-scan base-package="com.ddw.service"></context:component-scan>
</beans>

jdbc.properties文件
driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
name
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值