基于注解的bean配置

时间:2023-03-09 17:39:38
基于注解的bean配置

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

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

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

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

基于注解的bean配置


2、DAO层类注解

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

基于注解的bean配置


3、Service层类注解

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

基于注解的bean配置