【IT之路】MyEclipse实现Spring集成
一、Maven工程导入Spring相关jar包
二、创建Spring配置文件
1、配置spring.xml,实现自动扫描
在src/main/resource下创建spring配置文件:spring.xml
设置为自动扫描dao和service
2、验证自动扫面方式实现service配置
编写测试类,调用验证service配置
三、web.xml配置,实现外部访问
1、web.xml配置
<!-- spring配置文件位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param>
<!-- spring监听器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2、部署web项目到tomcat
先执行Maven install进行Maven工程构建
再执行工程部署到tomcat(部署方式和普通java web项目部署一样)
见:【IT之路】MyEclipse部署java web项目到tomcat