标签:service 表现层 main nts div col static vat inter
package com.example.service.ui; import com.example.service.IAccountService; import com.example.service.impl.AccountServiceImpl; /** * 模拟一个表现层,用于调用业务层 */ public class Client { public static void main(String[] args) { IAccountService as=new AccountServiceImpl(); as.saveAccount(); } }
package com.example.service; /** * 账户业务层接口 */ public interface IAccountService { /** * 模拟保存账户 */ void saveAccount(); }
package com.example.service.impl; import com.example.service.IAccountService; import com.example.service.dao.IAccountDao; import com.example.service.dao.impl.AccountDaoImpl; /** * 账户的业务层实现类 */ public class AccountServiceImpl implements IAccountService { private IAccountDao accountDao=new AccountDaoImpl(); @Override public void saveAccount() { accountDao.saveAccount(); } }
package com.example.service.dao; /** * 账户的持久层接口 */ public interface IAccountDao { /** * 模拟保存账户 */ void saveAccount(); }
package com.example.service.dao.impl; import com.example.service.dao.IAccountDao; /** * 账户的持久层实现类 */ public class AccountDaoImpl implements IAccountDao { @Override public void saveAccount(){ System.out.println("保存了账户"); } }
标签:service 表现层 main nts div col static vat inter
原文地址:https://www.cnblogs.com/abuduri/p/13282135.html