codecamp

配置文件factorys.properites的使用

接口与实现类的关联关系,也可以配置在配置文件factorys.properties文件中,在该配置文件中配置的实现类,其version值为10.

在src目录下面创建factorys.properties文件,然后写一个实现类并配置进去,如下

public class TestProdectDaoImpl implements ProductDao
{
	public List<Product> findAll() throws Exception {
		System.out.println("TestProdectDaoImpl findAll");
		return null;
	}
	public void save(Product product) throws Exception {
		System.out.println("TestProdectDaoImpl save");
		
	}
}

注意实现类无需添加任何注解

factorys.properties中配置如下

demo.dao.ProductDao=demo.dao.impl.TestProdectDaoImpl

再次调用测试,发现使用的是配置文件中的实现类了



重写个别方法
手动注册
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }