以下两个类分别使用配置形式与注解形式加入 IOC 容器中
service.impl.UserInfoService
@Data
@Service
public class UserInfoService implements IUserInfoService {
private UserInfoDao userMapper;
}
dao.impl.UserInfoDaoImpl
@Data
@Repository
public class UserInfoDaoImpl implements UserInfoDao {
}
一、配置形式
<bean id="userInfoDaoImpl" class="dao.impl.UserInfoDaoImpl"></bean>
<bean id="userInfoService" class="service.impl.UserInfoService">
<property name="userMapper" ref="userInfoDaoImpl"></property>
</bean>
二、@Configuration 注解形式
1、@ComponentScan与@Autowired
@Configuration
@ComponentScan(value = "service.impl,dao.impl")
public class MyConfig {
}
@Data
@Service
public class UserInfoService implements IUserInfoService {
@Autowired