Java --- springcloud初始项目创建

目录

一、cloud项目创建

1.1、项目编码规范

1.2、注解生效激活 

1.3、导入父工程maven的pom依赖 

二、创建子工程并导入相关pom依赖 

2.1、相关配置文件 

2.1.1、数据库配置文件内容

2.1.2、自动生成文件配置内容

三、创建微服务8001子工程

3.1、导入相关pom依赖 

 3.2、创建yml配置文件及内容

3.3、相关测试代码

四、创建微服务80子工程

 4.1、导入相关pom依赖

 4.2、创建yml配置文件及内容

4.3、相关测试代码 

一、cloud项目创建

1.1、项目编码规范

1.2、注解生效激活 

1.3、导入父工程maven的pom依赖 

<packaging>pom</packaging><properties><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><hutool.version>5.8.22</hutool.version><lombok.version>1.18.26</lombok.version><druid.version>1.1.20</druid.version><mybatis.springboot.version>3.0.2</mybatis.springboot.version><mysql.version>8.0.11</mysql.version><swagger3.version>2.2.0</swagger3.version><mapper.version>4.2.3</mapper.version><fastjson2.version>2.0.40</fastjson2.version><persistence-api.version>1.0.2</persistence-api.version><spring.boot.test.version>3.1.5</spring.boot.test.version><spring.boot.version>3.2.0</spring.boot.version><spring.cloud.version>2023.0.0</spring.cloud.version><spring.cloud.alibaba.version>2022.0.0.0-RC2</spring.cloud.alibaba.version></properties><dependencyManagement><dependencies><!--springboot 3.2.0--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>${spring.boot.version}</version><type>pom</type><scope>import</scope></dependency><!--springcloud 2023.0.0--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring.cloud.version}</version><type>pom</type><scope>import</scope></dependency><!--springcloud alibaba 2022.0.0.0-RC2--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>${spring.cloud.alibaba.version}</version><type>pom</type><scope>import</scope></dependency><!--SpringBoot集成mybatis--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>${mybatis.springboot.version}</version></dependency><!--Mysql数据库驱动8 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version></dependency><!--SpringBoot集成druid连接池--><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency><!--通用Mapper4之tk.mybatis--><dependency><groupId>tk.mybatis</groupId><artifactId>mapper</artifactId><version>${mapper.version}</version></dependency><!--persistence--><dependency><groupId>javax.persistence</groupId><artifactId>persistence-api</artifactId><version>${persistence-api.version}</version></dependency><!-- fastjson2 --><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>${fastjson2.version}</version></dependency><!-- swagger3 调用方式 http://你的主机IP地址:5555/swagger-ui/index.html --><dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId><version>${swagger3.version}</version></dependency><!--hutool--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>${hutool.version}</version></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version><optional>true</optional></dependency><!-- spring-boot-starter-test --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>${spring.boot.test.version}</version><scope>test</scope></dependency></dependencies></dependencyManagement>

二、创建子工程并导入相关pom依赖 

<dependencies><!--Mybatis 通用mapper tk单独使用,自己独有+自带版本号--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.13</version></dependency><!-- Mybatis Generator 自己独有+自带版本号--><dependency><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-core</artifactId><version>1.4.2</version></dependency><!--通用Mapper--><dependency><groupId>tk.mybatis</groupId><artifactId>mapper</artifactId></dependency><!--mysql8.0--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!--persistence--><dependency><groupId>javax.persistence</groupId><artifactId>persistence-api</artifactId></dependency><!--hutool--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency></dependencies><build><resources><resource><directory>${basedir}/src/main/java</directory><includes><include>**/*.xml</include></includes></resource><resource><directory>${basedir}/src/main/resources</directory></resource></resources><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin><plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.4.2</version><configuration><configurationFile>${basedir}/src/main/resources/generatorConfig.xml</configurationFile><overwrite>true</overwrite><verbose>true</verbose></configuration><dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><dependency><groupId>tk.mybatis</groupId><artifactId>mapper</artifactId><version>4.2.3</version></dependency></dependencies></plugin></plugins></build>

2.1、相关配置文件 

2.1.1、数据库配置文件内容

#t_pay表包名
package.name=com.cjc.cloud# mysql8.0
jdbc.driverClass = com.mysql.cj.jdbc.Driver
jdbc.url= jdbc:mysql://localhost:3306/cloud2024?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
jdbc.user = root
jdbc.password =123456

2.1.2、自动生成文件配置内容

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"><generatorConfiguration><properties resource="config.properties"/><context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat"><property name="beginningDelimiter" value="`"/><property name="endingDelimiter" value="`"/><plugin type="tk.mybatis.mapper.generator.MapperPlugin"><property name="mappers" value="tk.mybatis.mapper.common.Mapper"/><property name="caseSensitive" value="true"/></plugin><jdbcConnection driverClass="${jdbc.driverClass}"connectionURL="${jdbc.url}"userId="${jdbc.user}"password="${jdbc.password}"></jdbcConnection><javaModelGenerator targetPackage="${package.name}.entities" targetProject="src/main/java"/><sqlMapGenerator targetPackage="${package.name}.mapper" targetProject="src/main/java"/><javaClientGenerator targetPackage="${package.name}.mapper" targetProject="src/main/java" type="XMLMAPPER"/><table tableName="t_pay" domainObjectName="Pay"><generatedKey column="id" sqlStatement="JDBC"/></table></context>
</generatorConfiguration>

三、创建微服务8001子工程

3.1、导入相关pom依赖 

 <dependencies><!--SpringBoot通用依赖模块--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!--SpringBoot集成druid连接池--><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId></dependency><!-- Swagger3 调用方式 http://你的主机IP地址:5555/swagger-ui/index.html --><dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId></dependency><!--mybatis和springboot整合--><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId></dependency><!--Mysql数据库驱动8 --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!--persistence--><dependency><groupId>javax.persistence</groupId><artifactId>persistence-api</artifactId></dependency><!--通用Mapper4--><dependency><groupId>tk.mybatis</groupId><artifactId>mapper</artifactId></dependency><!--hutool--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId></dependency><!-- fastjson2 --><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.28</version><scope>provided</scope></dependency><!--test--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

 3.2、创建yml配置文件及内容

server:port: 8001# ==========applicationName + druid-mysql8 driver===================
spring:application:name: cloud-payment-servicedatasource:type: com.alibaba.druid.pool.DruidDataSourcedriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/cloud2024?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowPublicKeyRetrieval=trueusername: rootpassword: 123456# ========================mybatis===================
mybatis:mapper-locations: classpath:mapper/*.xmltype-aliases-package: com.cjc.cloud.entitiesconfiguration:map-underscore-to-camel-case: true

3.3、相关测试代码

实体类

/*** 表名:t_pay* 表注释:支付交易表
*/
@Table(name = "t_pay")
@Schema(title = "支付交易表实体类")
@Data
public class Pay {@Id@GeneratedValue(generator = "JDBC")@Schema(title = "主键id")private Integer id;/*** 支付流水号*/@Column(name = "pay_no")@Schema(title = "支付流水号")private String payNo;/*** 订单流水号*/@Column(name = "order_no")@Schema(title = "订单流水号")private String orderNo;/*** 用户账号ID*/@Column(name = "user_id")@Schema(title = "用户账号ID")private Integer userId;/*** 交易金额*/@Schema(title = "交易金额")private BigDecimal amount;/*** 删除标志,默认0不删除,1删除*/@Schema(title = "删除标志")private Byte deleted;/*** 创建时间*/@Column(name = "create_time")@Schema(title = "创建时间")//统一时间格式@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")private Date createTime;/*** 更新时间*/@Column(name = "update_time")@Schema(title = "更新时间")@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")private Date updateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PayDTO implements Serializable {private Integer id;//支付流水号private String payNo;//订单流水号private String orderNo;//用户账号IDprivate Integer userId;//交易金额private BigDecimal amount;
}

mapper接口

public interface PayMapper extends Mapper<Pay> {
}

mapper映射文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cjc.cloud.mapper.PayMapper"><resultMap id="BaseResultMap" type="com.cjc.cloud.entities.Pay"><!--WARNING - @mbg.generated--><id column="id" jdbcType="INTEGER" property="id" /><result column="pay_no" jdbcType="VARCHAR" property="payNo" /><result column="order_no" jdbcType="VARCHAR" property="orderNo" /><result column="user_id" jdbcType="INTEGER" property="userId" /><result column="amount" jdbcType="DECIMAL" property="amount" /><result column="deleted" jdbcType="TINYINT" property="deleted" /><result column="create_time" jdbcType="TIMESTAMP" property="createTime" /><result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /></resultMap>
</mapper>

service接口及实现类

public interface PayService {public int addPay(Pay pay);public int updatePay(Pay pay);public int removePay(Integer id);public Pay getById(Integer id);public List<Pay> getAll();
}
@Service
public class PayServiceImpl implements PayService {@Resourceprivate PayMapper payMapper;@Overridepublic int addPay(Pay pay) {return payMapper.insertSelective(pay);}@Overridepublic int updatePay(Pay pay) {return payMapper.updateByPrimaryKeySelective(pay);}@Overridepublic int removePay(Integer id) {return payMapper.deleteByPrimaryKey(id);}@Overridepublic Pay getById(Integer id) {return payMapper.selectByPrimaryKey(id);}@Overridepublic List<Pay> getAll() {return payMapper.selectAll();}
}

 swagger配置类

@Configuration
public class Swagger3Config {@Beanpublic GroupedOpenApi PayApi(){return GroupedOpenApi.builder().group("支付微服务模块").pathsToMatch("/pay/**").build();}@Beanpublic GroupedOpenApi OtherApi(){return GroupedOpenApi.builder().group("其它微服务模块").pathsToMatch("/other/**", "/others").build();}/*@Beanpublic GroupedOpenApi CustomerApi(){return GroupedOpenApi.builder().group("客户微服务模块").pathsToMatch("/customer/**", "/customers").build();}*/@Beanpublic OpenAPI docsOpenApi(){return new OpenAPI().info(new Info().title("cloud2024").description("通用设计rest").version("v1.0")).externalDocs(new ExternalDocumentation().description("www.cjc.com").url("https://yiyan.baidu.com/"));}
}

相关工具类

@Getter
public enum ReturnCodeEnum {/**操作失败**/RC999("999","操作XXX失败"),/**操作成功**/RC200("200","success"),/**服务降级**/RC201("201","服务开启降级保护,请稍后再试!"),/**热点参数限流**/RC202("202","热点参数限流,请稍后再试!"),/**系统规则不满足**/RC203("203","系统规则不满足要求,请稍后再试!"),/**授权规则不通过**/RC204("204","授权规则不通过,请稍后再试!"),/**access_denied**/RC403("403","无访问权限,请联系管理员授予权限"),/**access_denied**/RC401("401","匿名用户访问无权限资源时的异常"),RC404("404","404页面找不到的异常"),/**服务异常**/RC500("500","系统异常,请稍后重试"),RC375("375","数学运算异常,请稍后重试"),INVALID_TOKEN("2001","访问令牌不合法"),ACCESS_DENIED("2003","没有权限访问该资源"),CLIENT_AUTHENTICATION_FAILED("1001","客户端认证失败"),USERNAME_OR_PASSWORD_ERROR("1002","用户名或密码错误"),BUSINESS_ERROR("1004","业务逻辑异常"),UNSUPPORTED_GRANT_TYPE("1003", "不支持的认证模式");private final String code;private final String message;ReturnCodeEnum(String code, String message) {this.code = code;this.message = message;}//普通遍历public static ReturnCodeEnum returnCodeEnum1(String code){for (ReturnCodeEnum returnCodeEnum : ReturnCodeEnum.values()) {if (returnCodeEnum.getCode().equalsIgnoreCase(code)){return returnCodeEnum;}}return null;}//stream流public static ReturnCodeEnum returnCodeEnum2(String code){return Arrays.stream(ReturnCodeEnum.values()).filter(x -> x.getCode().equalsIgnoreCase(code)).findFirst().orElse(null);}public static void main(String[] args) {System.out.println(returnCodeEnum1("256"));System.out.println(returnCodeEnum2("200").getMessage());}
}
@Data
@Accessors(chain = true)
public class ResultData<T> {private String code;private String message;private T data;private long timestamp;//接口调用时间public ResultData() {this.timestamp = System.currentTimeMillis();}//成功public static <T> ResultData<T> success(T data){ResultData resultData = new ResultData<>();resultData.setCode(ReturnCodeEnum.RC200.getCode());resultData.setMessage(ReturnCodeEnum.RC200.getMessage());resultData.setData(data);return resultData;}//失败public static <T> ResultData<T> fail(String code, String message){ResultData resultData = new ResultData<>();resultData.setCode(code);resultData.setMessage(message);resultData.setData(null);return resultData;}
}
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {@ExceptionHandler({NullPointerException.class,RuntimeException.class})@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)public ResultData<String> exception(Exception e){System.out.println("come in GlobalExceptionHandler");log.error("全局异常信息:{}",e.getMessage(),e);return ResultData.fail(ReturnCodeEnum.RC500.getCode(),ReturnCodeEnum.RC500.getMessage());}
}

controller层

@RestController
@Slf4j
@Tag(name = "支付模块",description = "支付CURD")
public class PayController {@Autowiredprivate PayService payService;@Operation(summary = "添加",description = "添加支付流水方法")@PostMapping(value = "/pay/add")public ResultData<String> addPay(@RequestBody Pay pay){int i = payService.addPay(pay);if (i > 0){return ResultData.success("添加成功" + i);} else {return ResultData.fail(ReturnCodeEnum.RC999.getCode(),ReturnCodeEnum.RC999.getMessage());}}@PutMapping(value = "/pay/update")@Operation(summary = "修改",description = "修改支付流水方法")public ResultData<String> updatePay(@RequestBody PayDTO payDTO){Pay pay = new Pay();BeanUtils.copyProperties(payDTO,pay);int i = payService.updatePay(pay);if (i > 0){return ResultData.success("修改成功" + i);} else {return ResultData.fail(ReturnCodeEnum.RC999.getCode(),ReturnCodeEnum.RC999.getMessage());}}@DeleteMapping("/pay/remove/{id}")@Operation(summary = "删除",description = "删除支付流水方法")public ResultData<String> removePayId(@PathVariable("id") Integer id){int i = payService.removePay(id);if (i > 0){return ResultData.success("删除成功" + i);} else {throw new RuntimeException("删除失败");}}@GetMapping(value = "/pay/getById/{id}")@Operation(summary = "根据id查询",description = "根据流水id查询")public ResultData<Pay> getById(@PathVariable("id") Integer id){Pay pay = payService.getById(id);if (!pay.equals(null)){return ResultData.success(pay);}else {throw new RuntimeException("查询为空");}}@GetMapping(value = "/pay/getAll")@Operation(summary = "查询全部流水",description = "查询所以流水信息")public ResultData<List<Pay>> getAll(){List<Pay> all = payService.getAll();if (all.size() >= 0){return ResultData.success(all);}else{throw new RuntimeException("查询为空");}}
}

四、创建微服务80子工程

 4.1、导入相关pom依赖

    <dependencies><!--web + actuator--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><!--hutool-all--><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId></dependency><!--fastjson2--><dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId></dependency><!-- swagger3 调用方式 http://你的主机IP地址:5555/swagger-ui/index.html --><dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build>

 4.2、创建yml配置文件及内容

server:port: 80

4.3、相关测试代码 

@RestController
public class OrderController {public static final String URL = "http://localhost:8001";@Autowiredprivate RestTemplate restTemplate;//添加@GetMapping("/consumer/pay/add")public ResultData addOrder(PayDTO payDTO){return restTemplate.postForObject(URL + "/pay/add", payDTO, ResultData.class);}//删除@GetMapping("/consumer/pay/remove/{id}")public ResultData removeOrder(@PathVariable("id") Integer id){restTemplate.delete(URL + "/pay/remove/"+id,id);return ResultData.success(null);}//修改@GetMapping("/consumer/pay/update")public ResultData updateOrder(PayDTO payDTO){restTemplate.put(URL + "/pay/update", payDTO);return ResultData.success(null);}//查询@GetMapping("/consumer/pay/getById/{id}")public ResultData getByIdOrder(@PathVariable("id") Integer id){return restTemplate.getForObject(URL+ "/pay/getById/"+id,ResultData.class,id);}
}

 

 

 

 

 

 

 

 

 

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/730068.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

数据结构从入门到精通——栈

栈 前言一、栈1.1栈的概念及结构1.2栈的实现1.3栈的面试题 二、栈的具体实现代码栈的初始化栈的销毁入栈出栈返回栈顶元素返回栈中的元素个数检测是否为空Stack.hStack.ctest.c 前言 栈&#xff0c;作为一种后进先出&#xff08;LIFO&#xff09;的数据结构&#xff0c;在计算…

NTFS Disk by Omi NTFS for mac v1.1.4中文版

NTFS Disk by Omi NTFS for Mac&#xff1a;NTFS文件系统的无缝桥梁 软件下载&#xff1a;NTFS Disk by Omi NTFS for mac v1.1.4中文版 &#x1f310; 跨平台访问&#xff0c;文件无阻 NTFS Disk by Omi NTFS for Mac 为您的Mac提供了对NTFS文件系统的无缝访问。无论您是在Win…

Unity插件之天气系统UniStorm

首先呢&#xff0c;它是一款强大的动态昼夜天气系统&#xff0c;能够以较快的帧速率创建AAA级动态生成的天气、照明和天空&#xff0c;并且具有300多个可定制的组件&#xff0c;允许用户创建任何可以想象的环境。 第一步&#xff1a;他需要两个物体Camera摄像机、Player播放器…

鸿蒙开发-UI-动画-页面内动画

鸿蒙开发-UI-组件2 鸿蒙开发-UI-组件3 鸿蒙开发-UI-气泡/菜单 鸿蒙开发-UI-页面路由 鸿蒙开发-UI-组件导航-Navigation 鸿蒙开发-UI-组件导航-Tabs 鸿蒙开发-UI-图形-图片 鸿蒙开发-UI-图形-绘制几何图形 鸿蒙开发-UI-图形-绘制自定义图形 文章目录 前言 一、概述 二、页面内…

新一代信息技术下,AI如何重塑售前工作

近期&#xff0c;“新质生产力”一词犹如一颗璀璨的新星&#xff0c;频繁地在各大媒体平台上抢占热点位置&#xff0c;引发了大家的关注。关于“新质生产力”官方的解释是科技创新驱动经济高质量发展的必然产物&#xff0c;它代表着新一轮科技革命和产业变革的重要方向。 在今…

finishConnect(..) failed: Connection refused,服务本地正常服务器网关报400,nacos服务实例不能下线

①application里固定ip # Spring spring:cloud:inetutils:preferred-networks: 127.0.0.1 ②找到nacos服务下的protocol&#xff0c;删除下面所有&#xff0c;/nacos-server/data/protocol&#xff0c;删了不会有问题&#xff0c;而且这东西越用越大&#xff0c;删了好爽 ③重…

const XX=void0

在阅读源码中&#xff0c;经常会看到 const XXvoid0这里的 void 0其实就是 undefined&#xff0c;void 运算符总会返回一个 undefined 的结果。 那么&#xff0c;为什么要用 void 0 代替 undefined 呢&#xff1f; 总结&#xff1a; undefined 是一个「全局对象&#xff08;…

iOS——【自动引用计数】ARC规则及实现

1.3.3所有权修饰符 所有权修饰符一共有四种&#xff1a; __strong 修饰符__weak 修饰符__undafe_unretained 修饰符__autoreleasing 修饰符 __strong修饰符 _strong修饰符表示对对象的强引用&#xff0c;持有强引用的变量在超出其作用域的时候会被废弃&#xff0c;随着强引…

数组连续和 - 华为OD统一考试(C卷)

OD统一考试&#xff08;C卷&#xff09; 分值&#xff1a; 100分 题解&#xff1a; Java / Python / C 题目描述 给定一个含有N个正整数的数组&#xff0c;求出有多少连续区间&#xff08;包括单个正整数&#xff09;&#xff0c;它们的和大于等于 x。 输入描述 第一行为两个…

Xcode升级到Xcode15.1或15.2之后,无法新建Category和Extension文件,如何解决?

项目场景&#xff1a; Xcode升级到15.1或15.2之后&#xff0c;无法新建Category和Extension文件&#xff0c;并且Xcode不报任何错误 问题描述 Xcode升级到15.1或15.2之后&#xff0c;无法新建Category和Extension文件&#xff0c;并且Xcode不报任何错误。 具体的操作步骤如下…

redis-集群 原生部署和工具自动部署

什么redis集群&#xff1f; redis集群是一个提供在多个redis节点之间共享数据的程序集。它并不像redis主从复制模式那样仅提供一个master节点来提供写服务&#xff0c;而是会提供多个master节点来提供写服务&#xff0c;每个master节点中存储的数据都不一样&#xff0c;这些数据…

【保姆级爬虫】微博关键词搜索并获取博文和评论内容(python+selenium+chorme)

微博爬虫记录 写这个主要是为了防止自己忘记以及之后的组内工作交接&#xff0c;至于代码美不美观&#xff0c;写的好不好&#xff0c;统统不考虑&#xff0c;我只能说&#xff0c;能跑就不错了&#xff0c;上学压根没学过python好吧&#xff0c;基本上是crtlc&ctrlv丝滑小…

开启AI绘画新纪元:让创意在指尖绽放

文章目录 一、了解AI绘画的基本原理二、选择合适的AI绘画工具三、掌握AI绘画的基本技巧四、借鉴与创新&#xff1a;从模仿到创作五、参与社区交流&#xff0c;共同成长《AI绘画教程&#xff1a;Midjourney使用方法与技巧从入门到精通》亮点推荐内容简介作者简介目录 在科技日新…

Linux centos 常用的网络负载和网速查看工具和命令

在 CentOS 上查看网络速度和网络负载&#xff0c;可以使用多种工具&#xff0c;以下是一些常用的命令行工具&#xff1a; iftop - 用于实时监视网络带宽使用情况。 安装命令&#xff1a; sudo yum install iftop 使用命令&#xff1a; sudo iftop nload - 一个简单的控制…

Doris-数据分区

数据分区&#xff1a;即将大表划分为小表&#xff0c;数据分区主要有两个级别&#xff1a;Partition和Bucket&#xff08;Tablet&#xff09;。 Partition&#xff1a;逻辑分区&#xff0c;按照一定规则将表按照行进行划分&#xff0c;每个部分就是一个Partition。 Bucket&…

flink重温笔记(十):Flink 高级 API 开发——flink 四大基石之 State(涉及Checkpoint)

Flink学习笔记 前言&#xff1a;今天是学习 flink 的第 10 天啦&#xff01;学习了 flink 四大基石之 State &#xff08;状态&#xff09;&#xff0c;主要是解决大数据领域增量计算的效果&#xff0c;能够保存已经计算过的结果数据状态&#xff01;重点学习了 state 的类型划…

相对于 Linux,Windows Server 存在的意义是什么?

相对于 Linux&#xff0c;Windows Server 存在的意义是什么&#xff1f; 在开始前我有一些资料&#xff0c;是我根据网友给的问题精心整理了一份「Linux 的资料从专业入门到高级教程」&#xff0c; 点个关注在评论区回复“888”之后私信回复“888”&#xff0c;全部无偿共享给…

新版AndroidStudio的Gradle窗口显示task list not built 问题解决

在使用新版AndroidStudio时&#xff0c;会出现&#xff0c;Task List not built 的问题。如果你记得task的名字&#xff0c;当然可以 直接通过命令 gradle taskname 或者 ./gradlew taskName直接执行即可&#xff0c;但是若是记不住&#xff0c;还是把这个任务构建处理比较好用…

借助工具优化开发流程,提升开发体验

背景 最近在做一个demo&#xff0c;只有一个html页面&#xff0c;需要开启一个https web server&#xff0c;以此来实现在浏览器中访问。 改造前 改造前&#xff0c;每次修改文件保存后都要刷新一下浏览器。 如果只是短时间&#xff0c;每次修改后手动刷新浏览器也还行。主要…

C++:Stack和Queue的模拟实现

创作不易&#xff0c;感谢三连&#xff01; 一、容器适配器 适配器是一种设计模式(设计模式是一套被反复使用的、多数人知晓的、经过分类编目的、代码设计经验的总结)&#xff0c;该种模式是将一个类的接口转换成客户希望的另外一个接口。 就如同是电源适配器将不适用的交流电…