赞
踩
为什么
使用这个三个版本,是有讲究的;spring boot 2.2.2
,spring cloud Hoxton.SR1
,spring cloud alibaba 2.1.0.RELEASE
父工程坐标:
<groupId>cn.cookily.springcloud</groupId>
<artifactId>cloud2020</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
cloud-api-commons坐标:
<groupId>cn.cookily.springcloud</groupId>
<artifactId>cloud2020</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
子模块可以精简写
groupId,version,因为子模块继承父模块,所以gv可以省略
packaging可以省略
packaging
不显示声明
默认为jar
类型
cloud-api-commons坐标可改为:
<artifactId>cloud2020</artifactId>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cloud2020</artifactId>
<groupId>cn.cookily.springcloud</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-api-commons</artifactId>
<name>cloud-api-commons</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</project>
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Payment implements Serializable
{
private Long id;
private String serial;
}
有小伙伴反应实体类代码
报错
用到Lombok,开发工具要装一下Lombok插件,idea如下,eclipse的自行百度
三个
构造方法:
一个无参构造
一个有参构造(三个参数)
一个有参构造(两个参数)(Integer code,String message) 没返回值的时候,别看蒙了
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T>
{
private Integer code;
private String message;
private T data;
public CommonResult(Integer code,String message)
{
this(code,message,null);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。