entity | action | biz |
model mapper | controller | service impl |
applicationContext.xml
把mybatis给spring管理
①配置数据源ComboPooledDataSource
②配置mybatis要使用的SessionFactoryBean
1>要用的环境 datasource ref①
2>配置别名 typeAliasesPackage value="com.ssm.model"
③配置mapper的扫描 MapperScannerConfig
1>basePackage value="com.ssm.mapper"
④配置事务管理器
DataSourceTransactionManager
datasource ref①
⑤<tx:advice transaction-manager="④" ...
<tx:attributes>
<tx:method name="add*" proagetion="REQUIED"/>
update*..del*..
..read-only
⑥配置切点
<aop:config>
<aop:pointcut id="c" expression="execution(* com.ssm.service.impl.*.*(..))"/>
<aop:advisor advice-ref="⑤" pointcut-ref="c"></>
web.xml
配置 全局配置文件
<context:param>
<...name>contextConfigLocation</>
<...value>classpath:applicationContext.xml</>
....
配置监听器
<listener>
<..class>...ContextLoaderListener</>
<../>
---------------------------------------------------------------------------------------
注解
@Autowired
private usersMapper usersmapper;
将该属性所需要的对象依赖注入
@Service("usersmapper") impl写
实现接口里用,用于解决controller报错
@Service 为实现service写
@Resource(name="usersMapper",type=com.ssm.mapper.usersMapper.class)