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

网站全屏图片怎么做数据分析培训机构哪家好

网站全屏图片怎么做,数据分析培训机构哪家好,怎么买域名做企业网站,老板办公室装修设计1 Lombok 1.1 Lombok 介绍 (1)Lombok 作用 简化JavaBean开发,可以使用Lombok的注解让代码更加简洁Java项目中,很多没有技术含量又必须存在的代码:POJO的getter/setter/toString;异常处理;I/O…

1 Lombok

1.1 Lombok 介绍

(1)Lombok 作用

  • 简化JavaBean开发,可以使用Lombok的注解让代码更加简洁
  • Java项目中,很多没有技术含量又必须存在的代码:POJO的getter/setter/toString;异常处理;I/O流的关闭操作等等,这些代码既没有技术含量,又影响着代码的美观,Lombok应运而生

(2)SpringBoot 和 IDEA 官方支持

  • IDEA 2020已经内置了Lombok插件
  • SpringBoot 2.1.x之后的版本也在Starter中内置了Lombok依赖

1.2 Lombok 常用注解

  • @Data:注解在类上;提供所有属性的 getter 和 setter 方法,此外还提供了equals、canEqual、hashCode、toString 方法
  • @Setter:注解在属性上;为属性提供 setter 方法
  • @Getter:注解在属性上;为属性提供 getter 方法
  • @ToString:注解在类上;提供toString 方法
  • @Log4j:注解在类上;为类提供一个属性名为 log 的 Log4j 对象
  • @NoArgsConstructor:注解在类上;为类提供一个无参的构造方法
  • @AllArgsConstructor:注解在类上;为类提供一个全参的构造方法
  • @CleanUp:可以关闭流
  • @Builder:给被注解的类加个构造者模式
  • @Synchronized:加个同步锁
  • @SneakyThrows:等同于try/catch 捕获异常
  • @NotNull:如果给参数加个这个注解,参数为 null 时会抛出空指针异常
  • @Value:该注解和@Data类似,区别在于它会把所有成员变量默认定于为private final修饰,并且不会生成setter方法

Lombok扩展注解(需要在idea上安装Lombok插件才能使用) 

  • @Slf4j:注解在类上;为类提供一个属性名为 log 的 Slf4j 对象进行日志输出

1.3 Lombok 应用实例

需求说明:使用Lombok 简化实体类 Furn.java 代码,让代码简洁高效

代码实现

(1)Furn 实体类如下 

package com.springboot.bean;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component
@ConfigurationProperties(prefix = "furn01")
public class Furn {private Integer id;private String name;private Double price;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Double getPrice() {return price;}public void setPrice(Double price) {this.price = price;}
}

(2)在pom.xml中引入lombok,虽然springboot内置了lombok,但是如果要使用的话,仍然需要显示得引入一下

<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId>
</dependency>

不需要指定版本,版本在spring-boot-dependencies-2.5.3中指定了

但我这里出现了问题。这样设置后也无法使用Lombok的注解。解决方法:在pom文件设置高版本的Lombok

<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.28</version>
</dependency>

(3)修改 Furn.java 使用Lombok注解简化代码,可以通过idea自带的反编译功能,看Furn.class的源码,就可以看到生成的完整代码

简化代码如下

package com.springboot.bean;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@NoArgsConstructor
@AllArgsConstructor
@Data
@Component
@ConfigurationProperties(prefix = "furn01")
public class Furn {private Integer id;private String name;private Double price;
}

在目录 target/classes/com/springboot/bean/furn.class 即可看到反编译后的源码

完整源码如下 

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//package com.springboot.bean;import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;@Component
@ConfigurationProperties(prefix = "furn01"
)
public class Furn {private Integer id;private String name;private Double price;public Furn() {}public Furn(final Integer id, final String name, final Double price) {this.id = id;this.name = name;this.price = price;}public Integer getId() {return this.id;}public String getName() {return this.name;}public Double getPrice() {return this.price;}public void setId(final Integer id) {this.id = id;}public void setName(final String name) {this.name = name;}public void setPrice(final Double price) {this.price = price;}public boolean equals(final Object o) {if (o == this) {return true;} else if (!(o instanceof Furn)) {return false;} else {Furn other = (Furn)o;if (!other.canEqual(this)) {return false;} else {label47: {Object this$id = this.getId();Object other$id = other.getId();if (this$id == null) {if (other$id == null) {break label47;}} else if (this$id.equals(other$id)) {break label47;}return false;}Object this$price = this.getPrice();Object other$price = other.getPrice();if (this$price == null) {if (other$price != null) {return false;}} else if (!this$price.equals(other$price)) {return false;}Object this$name = this.getName();Object other$name = other.getName();if (this$name == null) {if (other$name != null) {return false;}} else if (!this$name.equals(other$name)) {return false;}return true;}}}protected boolean canEqual(final Object other) {return other instanceof Furn;}public int hashCode() {int PRIME = true;int result = 1;Object $id = this.getId();result = result * 59 + ($id == null ? 43 : $id.hashCode());Object $price = this.getPrice();result = result * 59 + ($price == null ? 43 : $price.hashCode());Object $name = this.getName();result = result * 59 + ($name == null ? 43 : $name.hashCode());return result;}public String toString() {return "Furn(id=" + this.getId() + ", name=" + this.getName() + ", price=" + this.getPrice() + ")";}
}

2 Spring Initailizr

2.1 Spring Initailizr 作用

通过Spring官方提供的Spring Initailizr 来构建Maven项目,能完美支持IDEA和Eclipse,让程序员来选择需要的开发场景(starter),还能自动生成启动类和单元测试代码

需要注意得是 Spring Initailizr 对Idea版本有要求,同时还要走网络

2.2  Spring Initailizr 使用演示

需求说明:使用 Spring Initailizr 创建SpringBoot项目,并支持web应用场景,支持MyBatis

2.2.1 方式1:IDEA 创建

(1)文件->新建->项目

(2)选择 Spring Initailizr (如果看不到这个项,需要安装 Spring Initailizr 插件) 

(3)效果如下

 

2.2.2 方式2:start.spring.io 创建

(1)打开网站  start.spring.io

 

(2)将该压缩包解压后使用IDEA打开,效果如下

 

http://www.yayakq.cn/news/412760/

相关文章:

  • 阳曲网站建设推荐咨询注册域名免费永久
  • 做黑彩网站为国外的公司提供网站建设 维护
  • 阿里云 wordpress 建站网站建设需要多少资金
  • 品牌营销型网站建设公司网络推广工作内容
  • 深圳金鼎网站建设如何登录微信公众号管理平台
  • 关于企业网站建设数据现状分析模板王字库官方下载
  • 免费创建个人商城网站吗golang 网站开发
  • 武功县住房与城乡建设局网站北京网站优化推广方案
  • 微网站和网站同步像素太原网站免费制作
  • 西安微网站开发能用VUE做网站
  • 福建设厅官方网站川畅科技网站设计
  • 哪个网站可以做线上翻译赚钱手加工外包加工网
  • 无锡网站建设报价做二手车网站怎么做的
  • 做网站北京公司业之峰装饰公司简介
  • 购物网站开发简介哪个网站找人做网页比较好
  • 招聘网站免费平台wordpress调节宽度
  • 在线crm网站历史价格查询
  • 番禺高端网站建设公司网站搜索条怎么做
  • 山东济南网站建设公司排名wordpress多站点的路径
  • ssh蒙语网站开发网页免费建站
  • 郑州网站建设品牌网站不备案行吗
  • 做外卖在哪个网站做好昆明昌盛网络技术有限公司
  • 有网站建设费科目吗网站404错误来源
  • 网站咨询聊天怎么做店铺设计图
  • 惠州seo建站交互式网站
  • 装修公司做自己网站高端定制品牌
  • 企业备案网站名称怎么填自贡市城市建设投资开发集团有限公司网站
  • 南宁网络营销网站视频软件app
  • 域名租赁网站天津seo招聘
  • 建站优化是什么怎么让WORDPRESS首页显示菜单