基于注解的bean配置

Posted on 2017-01-07 19:13  乐嗨  阅读(318)  评论(0)    收藏  举报

基于注解的bean配置,主要是进行applicationContext.xml配置、DAO层类注解、Service层类注解。

1、在applicationContext.xml文件中配置信息如下

 <!--定义服务层代码存放的包扫描路径-->
 <context:component-scan base-package="org.mainstudio.com.service,org.mainstudio.com.dao" />

其中base-package包括了要进行注解类所在的包,多个用“,”隔开。


2、DAO层类注解

@Repository("commodityDao")
public class CommodityDaoImpl implements CommodityDao


3、Service层类注解

@Service("commodityService")
public class CommodityServiceImpl implements CommodityService