67,513
社区成员
发帖
与我相关
我的任务
分享
public interface IAuthenticateDAO {
public boolean IsAvailableInTheAccount(AuthenticateVO authenticateVO);
public boolean IsAlreadyCertified(AuthenticateVO authenticateVO);
public void addAuthenticationInfoAndGiftLine(AuthenticateVO authenticateVO);
}
public class PhoneAuthenticateDAOImpl implements IAuthenticateDAO {
public boolean IsAvailableInTheAccount(AuthenticateVO authenticateVO) {
return false;
}
public boolean IsAlreadyCertified(AuthenticateVO authenticateVO) {
return false;
}
public void addAuthenticationInfoAndGiftLine(AuthenticateVO authenticateVO) {
}
}
public class EmailAuthenticateDAOImpl implements IAuthenticateDAO {
@Override
public boolean IsAvailableInTheAccount(AuthenticateVO authenticateVO) {
return false;
}
@Override
public boolean IsAlreadyCertified(AuthenticateVO authenticateVO) {
return false;
}
@Override
public void addAuthenticationInfoAndGiftLine(AuthenticateVO authenticateVO) {
}
}
@Service("authenticateService")
public class AuthenticateServiceImpl implements IAuthenticateService {
@Inject
private IAuthenticateDAO phoneAuthenticateDAO;
@Inject
private IAuthenticateDAO emailAuthenticateDAO;
}
@Repository
public class daoImpl implements dao{
@Resource
Idatabase idb;
void save(T entity){ idb.executeSQL(entity);//实现类 SaveImpl中重写的方法 }
void update(T entity){ idb.executeSQL(entity);//实现类 UpdateImpl中重写的方法 }
void remove(T entity){ idb.executeSQL(entity);//实现类 RemoveImpl中重写的方法 }
}
在以上代码我们希望由容器判断该注入什么类,但是实际上貌似不行,会抛出异常。