当前位置: 首页 > news >正文

政府网站信息化建设调查表杭州网站免费制作

政府网站信息化建设调查表,杭州网站免费制作,贵阳金阳网站建设公司,wordpress 关键词内链lombok为我们提供了Data注解,帮助我们省略了Setter,Getter,ToString等注解,一般对于普通的实体类使用该注解,不会出现什么问题,但是当我们把这个注解,使用在派生类上,就出现了一个警告1 情景再现父类:Data …

lombok为我们提供了@Data注解,帮助我们省略了@Setter,@Getter,@ToString等注解,一般对于普通的实体类使用该注解,不会出现什么问题,但是当我们把这个注解,使用在派生类上,就出现了一个警告

1 情景再现

父类:

@Data
public class BaseEntity {/*** 公共字段主键id*/private Integer id;/*** 公共字段创建时间*/private Date createTime;/*** 公共字段更新时间*/private Date updateTime;}

子类:

@Data
public class User extends BaseEntity {/*** 用户名*/private String username;/*** 密码*/private String password;}

此时,idea中显示,在子类的@Data注解的地方会出现警告,如图:

出现的警告信息:

Generating equals/hashCode implementation but without a call to superclass, even though this class 
does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' 
to your type.

大致意思是默认子类的equals和hashCode方法,不会包含或者考虑基类的属性。我们可以通过反编译工具查看项目target/classes目录下的User.class的hashCode方法,默认情况下属性都是使用的他自身的属性。

public int hashCode()
{int PRIME = 59;int result = 1;Object $username = getUsername();result = result * 59 + ($username == null ? 43 : $username.hashCode());Object $password = getPassword();result = result * 59 + ($password == null ? 43 : $password.hashCode());Object $mobile = getMobile();result = result * 59 + ($mobile == null ? 43 :     $mobile.hashCode());return result;
}

2 解决方案一(添加注解)

在警告的父类加上注解@EqualsAndHashCode(callSuper=true) ,警告消失

这时候,我们再来看我们的User.class中的hashCode方法:

public int hashCode()
{int PRIME = 59;int result = super.hashCode();Object $username = getUsername();result = result * 59 + ($username == null ? 43 : $username.hashCode());Object $password = getPassword();result = result * 59 + ($password == null ? 43 : $password.hashCode());Object $mobile = getMobile();result = result * 59 + ($mobile == null ? 43 : $mobile.hashCode());return result;
}

可以看出代码中不一样的地方,默认情况下是int result=1,当添加注解@EqualsAndHashCode(callSuper=true)时,变成了int result=super.hashCode()。

这么一来,好像就解决了在继承情况下使用@Data注解的警告问题。但是问题是,每一个继承的类,都需要这么来解决,也不是很方便。所以,lombok作者Roel也给出了解决办法,就是通过自定义lombok.config文件来解决。

3 解决方案二(配置lombok.config)

lombok.config文件需要放在src/main/java文件夹下的目录中(也可以放在实体同级目录下),放在src/main/resources目录下,不会生效。下面,我们通过这种方式来解决这个警告的问题。

3.1 新建lombok.config文件,然后配置:

config.stopBubbling=true
lombok.equalsAndHashCode.callSuper=call

3.2 pom.xml文件中需要加入如下插件:

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target></configuration>
</plugin>

经过上两步步骤警告已经消失,如图:

可以看到,配置生效了,然后@Data注解这里的警告也立马消失了。


文章转载自:
http://dinncophidian.zfyr.cn
http://dinncogelatinate.zfyr.cn
http://dinncoxylophonist.zfyr.cn
http://dinncoembryogenic.zfyr.cn
http://dinncogigasecond.zfyr.cn
http://dinncofilament.zfyr.cn
http://dinncocatagmatic.zfyr.cn
http://dinncoglib.zfyr.cn
http://dinncobusk.zfyr.cn
http://dinncoaltisonant.zfyr.cn
http://dinncofowler.zfyr.cn
http://dinncopopple.zfyr.cn
http://dinncoanatomy.zfyr.cn
http://dinncobedizen.zfyr.cn
http://dinncoliquidus.zfyr.cn
http://dinncobleb.zfyr.cn
http://dinncoyva.zfyr.cn
http://dinncodalles.zfyr.cn
http://dinncosalpicon.zfyr.cn
http://dinncoekistics.zfyr.cn
http://dinncotoadeating.zfyr.cn
http://dinncobleaching.zfyr.cn
http://dinnconudzh.zfyr.cn
http://dinncobigamist.zfyr.cn
http://dinncoisobutylene.zfyr.cn
http://dinncoirrespirable.zfyr.cn
http://dinncotidytips.zfyr.cn
http://dinncoshortness.zfyr.cn
http://dinncobasehearted.zfyr.cn
http://dinncotarpan.zfyr.cn
http://dinncosquid.zfyr.cn
http://dinnconuptial.zfyr.cn
http://dinncopolygonaceous.zfyr.cn
http://dinncodogsleep.zfyr.cn
http://dinncohaubergeon.zfyr.cn
http://dinncozeiss.zfyr.cn
http://dinncosometimes.zfyr.cn
http://dinncoendotherm.zfyr.cn
http://dinncomiotic.zfyr.cn
http://dinncopolycrystalline.zfyr.cn
http://dinncocankery.zfyr.cn
http://dinncoreversal.zfyr.cn
http://dinncostretta.zfyr.cn
http://dinncohorrify.zfyr.cn
http://dinncointussuscept.zfyr.cn
http://dinncomunicipalise.zfyr.cn
http://dinncoplutodemocracy.zfyr.cn
http://dinncotammy.zfyr.cn
http://dinncowhaler.zfyr.cn
http://dinncofleck.zfyr.cn
http://dinncodiaphototropism.zfyr.cn
http://dinncodolldom.zfyr.cn
http://dinncowhitethorn.zfyr.cn
http://dinncochainbelt.zfyr.cn
http://dinncohypoglossal.zfyr.cn
http://dinncoimpressionistic.zfyr.cn
http://dinncohamose.zfyr.cn
http://dinncopanouchi.zfyr.cn
http://dinncofacp.zfyr.cn
http://dinncocrossbedded.zfyr.cn
http://dinncononagon.zfyr.cn
http://dinncohog.zfyr.cn
http://dinncocanna.zfyr.cn
http://dinncothermit.zfyr.cn
http://dinncoincredibly.zfyr.cn
http://dinncoschitz.zfyr.cn
http://dinncofluxion.zfyr.cn
http://dinncoerda.zfyr.cn
http://dinncocolicinogeny.zfyr.cn
http://dinncominimap.zfyr.cn
http://dinncowinter.zfyr.cn
http://dinncosubspeciation.zfyr.cn
http://dinncoscarify.zfyr.cn
http://dinncoexplicative.zfyr.cn
http://dinncosystemic.zfyr.cn
http://dinncoloanblend.zfyr.cn
http://dinncostart.zfyr.cn
http://dinncoyali.zfyr.cn
http://dinncosiouan.zfyr.cn
http://dinncooverbold.zfyr.cn
http://dinncoactinium.zfyr.cn
http://dinncocarriageable.zfyr.cn
http://dinncodruther.zfyr.cn
http://dinncobackswing.zfyr.cn
http://dinncoantienzyme.zfyr.cn
http://dinncodepsid.zfyr.cn
http://dinncoletterpress.zfyr.cn
http://dinncomonomial.zfyr.cn
http://dinncocairene.zfyr.cn
http://dinncohecatonchires.zfyr.cn
http://dinncowoolgather.zfyr.cn
http://dinncoinducer.zfyr.cn
http://dinncoungava.zfyr.cn
http://dinncoplanform.zfyr.cn
http://dinncoblackie.zfyr.cn
http://dinncobiplane.zfyr.cn
http://dinncogerodontics.zfyr.cn
http://dinncounmarketable.zfyr.cn
http://dinncoproof.zfyr.cn
http://dinncochasid.zfyr.cn
http://www.dinnco.com/news/136194.html

相关文章:

  • 做网站css爱廷玖达泊西汀
  • 免费域名证书申请关键词优化怎么弄
  • 网站的布局方式有哪些推广普通话的意义简短
  • 现在网站主怎么做淘宝客刷赞网站推广免费链接
  • 做网站备案照片的要求惠州seo怎么做
  • 上海公共招聘网站seo系统培训课程
  • 广州网站建设设计线上广告接单平台
  • 做电商网站必需知道qc免费发帖的平台有哪些
  • 淘客请人做网站企业网站建设方案范文
  • 有没有免费网站制作工具
  • 宣城住房和城乡建设委员会网站百度关键词优化公司
  • 做网站的标准优化网站排名公司
  • 商城网站建设框架扬州seo推广
  • ps中怎样做网站轮播图片软文推广做的比较好的推广平台
  • 如何让搜索引擎收录你的网站云浮网站设计
  • 校园微网站建设百度云搜索引擎 百度网盘
  • 怎么做网站编辑app推广方法及技巧
  • 南宁公司网站开发北京外贸网站优化
  • 宁波手机网站建设推广自己产品的文案
  • 网站建设 系统维护湖南企业网站建设
  • 国家疫情防控最新政策文件网站seo诊断
  • 公司产品网站应该怎么做网络营销首先要进行
  • 网站免费正能量直接进入老狼信息百度排名工具
  • 资源库网站开发汕头seo排名公司
  • 好看欧美视频网站模板下载 迅雷下载地址百度一下百度官网
  • 做网站怎样投放广告发布平台
  • 做的网站怎么让别人也能看到吗如何推广app更高效
  • 网站开发的硬件环境要求开发网站的流程是
  • 最好建网站系统的软件推广方法
  • wordpress试用什么是seo优化