陈建华的博客
专注web开发
eclipse中Find/Replace使用正则表达式查找和替换
2015-09-16 10:32:39   阅读1669次

今天在使用eclipse的时候,我建了一个entity。如下:

public void settSnJieDaoJiChuService(TSnJieDaoJiChuService tSnJieDaoJiChuService) {
    this.tSnJieDaoJiChuService = tSnJieDaoJiChuService;
}
public void settSnDangYuanJiBenService(TSnDangYuanJiBenService tSnDangYuanJiBenService) {
    this.tSnDangYuanJiBenService = tSnDangYuanJiBenService;
}
public void settSnFaZhanDangYuanService(TSnFaZhanDangYuanService tSnFaZhanDangYuanService) {
    this.tSnFaZhanDangYuanService = tSnFaZhanDangYuanService;
}
public void settSnCunLiangWeiService(TSnCunLiangWeiService tSnCunLiangWeiService) {
    this.tSnCunLiangWeiService = tSnCunLiangWeiService;
}
public void settSnCunLiangWeiFuService(TSnCunLiangWeiFuService tSnCunLiangWeiFuService) {
    this.tSnCunLiangWeiFuService = tSnCunLiangWeiFuService;
}
public void settSnPrevYearJiTiShouRuService(TSnPrevYearJiTiShouRuService tSnPrevYearJiTiShouRuService) {
    this.tSnPrevYearJiTiShouRuService = tSnPrevYearJiTiShouRuService;
}
public void settSnHuoDongChangSuoService(TSnHuoDongChangSuoService tSnHuoDongChangSuoService) {
    this.tSnHuoDongChangSuoService = tSnHuoDongChangSuoService;
}
public void settSnXianJiBangBaoService(TSnXianJiBangBaoService tSnXianJiBangBaoService) {
    this.tSnXianJiBangBaoService = tSnXianJiBangBaoService;
}
public void settSnXianWeiPaiZhuService(TSnXianWeiPaiZhuService tSnXianWeiPaiZhuService) {
    this.tSnXianWeiPaiZhuService = tSnXianWeiPaiZhuService;
}
public void settSnLingDaoFenGongService(TSnLingDaoFenGongService tSnLingDaoFenGongService) {
    this.tSnLingDaoFenGongService = tSnLingDaoFenGongService;
}

上面的很容易实现,使用eclipse的create setter就可以。但是我想更进一步的实现功能,如下:

@Resource
public void settSnJieDaoJiChuService(TSnJieDaoJiChuService tSnJieDaoJiChuService) {
    this.tSnJieDaoJiChuService = tSnJieDaoJiChuService;
}

其实就是在每一个setter上加上@Resource。

用正则表达式如下:


QQ图片20150916103130.png

查找正则:\r\n\tpublic

替换正则:\r\n\t@Resource$0

别忘记勾选Regular expressions



-----------------------------------------------------
转载请注明来源此处
原地址:#

-----网友评论----
暂无评论
-----发表评论----
微网聚博客乐园 ©2014 blog.mn886.net 鲁ICP备14012923号   网站导航