1. 项目资源整合实现
前言:
笔者是基于注解方式实现的SSM整合
项目所需依赖:
所需jar包可以去 https://mvnrepository.com/ 下载。
1.1 配置架构分析
配置架构图:
● SpringRepositoryConfig是负责数据层配置
● SpringServiceConfig是负责业务层配置
● SpringWevConfig是负责请求处理层(控制层和视图层)配置
● WebInitializer是负责启动初始化(相当于web.xml文件)
创建配置类:
//数据层配置类
package com.wtl.common.config;
@Configuration
@MapperScan("com.wtl.goods.dao")//扫描dao
public class SpringRepositoryConfig {
}
//业务层配置类
package com.wtl.common.config;
@Configuration
@ComponentScan("com.wtl.goods.service")
public class SpringServiceConfig {
}
//控制层配置类
package com.wtl.common.config;
@Configuration
@EnableWebMvc
@ComponentScan("com.wtl.goods.controller"