【Nacos案例】

news2025/1/11 6:56:04

0、整体

整体项目概览

整体服务概览

在这里插入图片描述

1、新建父工程demo-nacos

删除src ,切记 packaging:pom

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>spring-boot-dependencies</artifactId>
		<groupId>org.springframework.boot</groupId>
		<version>2.3.2.RELEASE</version>
		<relativePath />
	</parent>
	<packaging>pom</packaging>
	<groupId>com.example</groupId>
	<artifactId>demo-nacos</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-nacos</name>
	<description>demo-nacos</description>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
		<alibaba-cloud.version>2.2.5.RELEASE</alibaba-cloud.version>
		<springcloud.version>Hoxton.SR8</springcloud.version>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${springcloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>com.alibaba.cloud</groupId>
				<artifactId>spring-cloud-alibaba-dependencies</artifactId>
				<version>${alibaba-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>2.0.19</version>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>

2、新建通用模块demo-nacos-common

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>demo-nacos</artifactId>
		<groupId>com.example</groupId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo-nacos-common</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-nacos-common</name>
	<description>demo-nacos-common</description>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
		</dependency>
	</dependencies>


	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<skip>true</skip>  <!-- 防止编译出错 -->
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

添加响应web实体类:

package com.example.demonacoscommon.entity;

import com.alibaba.fastjson.JSON;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 类描述: 返回前端的消息封装
 *
 * @author Administrator
 */
@Data
@AllArgsConstructor
public class RestApiResponse<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private static final String DEFAULT_MSG_SUC = "成功";

    private Object data;

    private String message;

    private int status;

    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<>();
        if (data != null) {
            map.put("data", this.getData());
        }
        if (message != null) {
            map.put("message", this.getMessage());
        }
        map.put("code", this.getStatus());
        return map;
    }

    protected RestApiResponse() {
        super();
    }

    protected RestApiResponse(Object data) {
        this.setStatus(200);
        this.data = data;
    }

    protected RestApiResponse(int code, Object data) {
        this.setStatus(code);
        this.message = DEFAULT_MSG_SUC;
        this.data = data;
    }

    public Object getData() {
        return data;
    }

    public RestApiResponse<T> setData(Object data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONStringWithDateFormat(this, "yyyy-MM-dd HH:mm:ss");
    }

    public static RestApiResponse<?> fromJson(String json) {
        return JSON.parseObject(json, RestApiResponse.class);
    }

    public String getMessage() {
        return message;
    }

    @SuppressWarnings("rawtypes")
    public RestApiResponse setMessage(String message) {
        this.message = message;
        return this;
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse ok() {
        return ok(null);
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse ok(Object data) {
        return new RestApiResponse(200, data);
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse error(String message) {
        return new RestApiResponse(500, null).setMessage(message);
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse error(String message, int status) {
        return new RestApiResponse().setStatus(status).setMessage(message);
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse error(String message, int status, Object data) {
        return new RestApiResponse(data).setStatus(status).setMessage(message);
    }

    @SuppressWarnings("rawtypes")
    public static RestApiResponse error(ResultStatus resultStatus) {
        return new RestApiResponse().setStatus(resultStatus.getCode()).setMessage(resultStatus.getMessage());
    }

    public int getStatus() {
        return status;
    }

    @SuppressWarnings("rawtypes")
    public RestApiResponse setStatus(int status) {
        this.status = status;
        return this;
    }
}

自定义请求状态码:

package com.example.demonacoscommon.entity;

/**
 * 类描述:自定义请求状态码
 */
public enum ResultStatus {
    USERNAME_OR_PASSWORD_ERROR(-1001, "用户名或密码错误"),
    USER_NOT_FOUND(-1002, "用户不存在"),
    USER_NOT_LOGIN(-1003, "用户未登录"),

    /**************** 修改密码 (-8000) ***************************/
    MODIFY_PASSWORD_SUCCESS(-8001, "密码修改成功!"),
    MODIFY_PASSWORD_FAIL(-8002, "密码修改失败!"),
    MODIFY_PASSWORD_NULL(-8003, "旧密码为空或者旧密码填写不正确!"),

    /**************** 参数 (-10000) ***************************/
    PARAM_NULL(100001, "参数不能为空"),
    PARAM_INCORRECT(100002, "参数不正确"),

    PC_CURRENT_ACTIVITY_CODE(100003, "节点不能为空"),


    /**************** 异常(90001) ***************************/
    CODE_EXCEPTION(90001, "代码异常");

    /**
     * 返回码
     */
    private int code;

    /**
     * 返回结果描述
     */
    private String message;

    ResultStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}

实体类:最好手动加上getter、setter

package com.example.demonacoscommon.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Administrator
 */
@Data
public class User {

    private Integer id;

    private String name;

    private String money;

    public User() {
    }

    public User(Integer id, String name, String money) {
        this.id = id;
        this.name = name;
        this.money = money;
    }

    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 String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }
}

3、生产者模块demo-nacos-provider

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>demo-nacos</artifactId>
		<groupId>com.example</groupId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo-nacos-provider</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-nacos-provider</name>
	<description>demo-nacos-provider</description>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
	</properties>

	<dependencies>
		<!-- nacos依赖 -->
		<dependency>
			<groupId>com.alibaba.cloud</groupId>
			<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
		</dependency>
		<!-- web -->
		<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>
		<!-- 我们创建的公共模块 -->
		<dependency>
			<groupId>com.example</groupId>
			<artifactId>demo-nacos-common</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
		</dependency>

		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
	</dependencies>

</project>

application.yml

server:
  port: ${port:9001}

spring:
  application:
    name: provider-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 3fcf3501-1f2e-46e7-8bb0-501c1b3f9db3
#  jackson:
#    serialization:
#      FAIL_ON_EMPTY_BEANS: false


启动类加注解:

package com.example.demonacosprovider;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient  // nacos客户端注解
public class DemoNacosProviderApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoNacosProviderApplication.class, args);
	}

}

新建controller:

package com.example.demonacosprovider.controller;

import com.example.demonacoscommon.entity.User;
import com.example.demonacoscommon.entity.RestApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/provider")
@Slf4j
public class ProviderController {

    public static HashMap<Integer, User> users = new HashMap<>(6);

    static {
        users.put(1, new User(1, "冷风扇1号", "111"));
        users.put(2, new User(2, "冷风扇2号", "222"));
        users.put(3, new User(3, "冷风扇3号", "333"));
        users.put(4, new User(4, "冷风扇4号", "444"));
        users.put(5, new User(5, "冷风扇5号", "555"));
        users.put(6, new User(6, "冷风扇6号", "666"));
    }

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/get")
    public RestApiResponse<User> executePay(@RequestParam("userId") Integer userId) {
        System.out.println("come in provider service port: " + serverPort);
        Map<String, User> resultMap = new HashMap(1);
        resultMap.put(serverPort, users.get(userId));
        return RestApiResponse.ok(resultMap);
    }

}

启动服务:允许多个实例(测试nacos的负载均衡):以及第二个启动的add vm options加上 -Dport=9002
在这里插入图片描述在这里插入图片描述可看到:
在这里插入图片描述

4、消费者模块demo-nacos-consumer

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>demo-nacos</artifactId>
		<groupId>com.example</groupId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo-nacos-consumer</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-nacos-consumer</name>
	<description>demo-nacos-consumer</description>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
	</properties>

	<dependencies>
		<dependency>
			<groupId>com.alibaba.cloud</groupId>
			<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
		</dependency>

		<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>

		<!-- 我们创建的公共模块 -->
		<dependency>
			<groupId>com.example</groupId>
			<artifactId>demo-nacos-common</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
		</dependency>

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

	</dependencies>
</project>

application.yml:

server:
  port: ${port:9101}
spring:
  application:
    name: consumer-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 3fcf3501-1f2e-46e7-8bb0-501c1b3f9db3
toserver:
  name: http://provider-service

启动类加注解:@EnableDiscoveryClient
负载均衡配置:

package com.example.demonacosconsumer.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author Administrator
 */
@Configuration
public class RibbonConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}

新建controller:

package com.example.demonacosconsumer.controller;

import com.example.demonacoscommon.entity.RestApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Value("${toserver.name}")
    private String toServerName;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/get/{userId}")
    public RestApiResponse<Object> consumer(@PathVariable("userId") Integer userId) {
        return restTemplate.getForObject(toServerName + "/provider/get?userId=" + userId, RestApiResponse.class, userId);
    }

}

启动:访问接口 http://localhost:9101/consumer/get/1
在这里插入图片描述刷新:
在这里插入图片描述

5、通过feign调用provider:

新建模块 demo-nacos-consumer-feign:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<artifactId>demo-nacos</artifactId>
		<groupId>com.example</groupId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo-nacos-consumer-feign</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo-nacos-consumer-feign</name>
	<description>demo-nacos-consumer-feign</description>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
	</properties>

	<dependencies>
		<dependency>
			<groupId>com.alibaba.cloud</groupId>
			<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
		</dependency>

		<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>

		<!-- 我们创建的公共模块 -->
		<dependency>
			<groupId>com.example</groupId>
			<artifactId>demo-nacos-common</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
		</dependency>

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

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-openfeign</artifactId>
		</dependency>


	</dependencies>

</project>

application.yml:

server:
  port: ${port:9101}
spring:
  application:
    name: consumer-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 3fcf3501-1f2e-46e7-8bb0-501c1b3f9db3
#toserver:
#  name: http://provider-service

启动类加注解:@EnableDiscoveryClient
@EnableFeignClients

负载均衡配置类:

package com.example.demonacosconsumerfeign.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author Administrator
 */
@Configuration
public class RibbonConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}

service:

package com.example.demonacosconsumerfeign.service;

import com.example.demonacoscommon.entity.RestApiResponse;
import com.example.demonacoscommon.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "provider-service")
public interface ProviderService {
    
    @GetMapping("/provider/get")
    RestApiResponse<User> executeProvider(@RequestParam("userId") Integer userId);

}

controller:

package com.example.demonacosconsumerfeign.controller;

import com.example.demonacoscommon.entity.RestApiResponse;
import com.example.demonacoscommon.entity.User;
import com.example.demonacosconsumerfeign.service.ProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Autowired
    private ProviderService providerService;


    @GetMapping("/get/{userId}")
    public RestApiResponse<User> consumer(@PathVariable("userId") Integer userId) {
        return providerService.executeProvider(userId);
    }

}

命名空间:
在这里插入图片描述

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

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

相关文章

[Apollo Cyber RT] Timer实现

Timer的实现方式 Timer有多种实现方式&#xff0c;CyberRT采用了时间轮(TimingWheel)方式。关于Timing Wheels的详细描述可以参考附录的链接。此处不赘述。 CyberRT Timer的类构成 实现细节 Timer Timer类是门户&#xff0c;但定时器真正的核心是TimingWheel。 Timer的定义…

索引的基础使用

索引&#xff1a; 分类&#xff1a; 功能逻辑&#xff1a;普通索引、唯一索引、主键索引、全文索引物理实现方式&#xff1a;聚簇索引&#xff0c;非聚簇索引作用字段个数&#xff1a;单列索引&#xff0c;联合索引 索引创建&#xff1a; --主键索引 CREATE TABLE dept( de…

SpringBoot的使用

一、Maven的环境搭建 暂时未完成.... 二、创建项目 创建完以后的目录如下&#xff1a; 然后配置pom.xml 再放入配置项 <!-- 2 我的依赖仓库源 , 首先配置仓库的服务器位置,首选阿里云&#xff0c;也可以配置镜像方式&#xff0c;效果雷同 --><repositories><re…

章节四:RASA 训练数据介绍

一、前言 一般来说&#xff0c;机器人可以跟人对话&#xff0c;机器人说什么是最难的&#xff0c;顶多是人工编写几种规则和模版来回复即可。但是要让机器人理解人的意图&#xff0c;确实非常难的事情。因为语言具有多样性&#xff0c;多义词&#xff0c;一语双关&#xff0c;…

872. 最大公约数(史上最详细讲解 7种算法,STL+算法标准实现)

一&#xff0c;什么是最大公约数 最大公约数&#xff08;Greatest Common Divisor&#xff09;指两个或多个整数共有约数中最大的一个。也称最大公因数、最大公因子&#xff0c;a&#xff0c; b的最大公约数记为&#xff08;a&#xff0c;b&#xff09;&#xff0c;同样的&…

测试架构工程师需要具备哪些能力 ?

目录 前言 为什么软件项目需要架构设计&#xff1f; 测试架构师需要解决什么问题&#xff1f; 测试架构师需要具备哪些能力&#xff1f; 测试工程师如何培养架构能力&#xff1f; 总结 重点&#xff1a;配套学习资料和视频教学 前言 相比于我们常见的研发架构师&#xf…

深入ftrace kprobe原理解析

Linux krpobe调试技术是内核开发者专门为了编译跟踪内核函数执行状态所涉及的一种轻量级内核调试技术&#xff0c;利用kprobe技术&#xff0c;内核开发人员可以在内核的绝大多数指定函数中动态插入探测点来收集所需的调试状态信息而基本不影响内核原有的执行流程。本章的是基于…

Spring-Mybatis整合 | 原理分析

&#x1f497;wei_shuo的个人主页 &#x1f4ab;wei_shuo的学习社区 &#x1f310;Hello World &#xff01; 文章目录▌环境搭建▌Mybatis流程回顾▌Mybatis-Spring整合SqlSessionTemplate方式SqlSessionTemplate分析configLocation & mapperLocations分析SqlSessionDaoSu…

ERD Online 4.0.3数据库在线建模(免费、更美、更稳定)

ERD Online 4.0.3❝ 全新升级&#xff0c;团队功能、权限管理、更美更稳定从这个版本&#xff0c;我们隆重推出低代码设计平台LOCO&#xff0c;见下文❞发展里程碑 4.0.3改动一览 功能完善 个人项目 个人项目即原有的项目管理&#xff0c;每个账号只能编辑自己的「个人项目」。…

linux下自动构建工具make:makefile

文章目录make/makefile介绍makefile的核心规则makefile的寻找规则makefile的伪目标什么是makefile&#xff1f;大多数人都应该是不太清楚的&#xff0c;因为现在人们基本都用着非常好的适合自己的IDE&#xff0c;而IDE为人们做了makefile该做的&#xff0c;从而导致大多数人并不…

同花顺_代码解析_技术指标_O

本文通过对同花顺中现成代码进行解析&#xff0c;用以了解同花顺相关策略设计的思想 目录 OBOS OBV OBVFS OI指标 OSC OBOS 超买超卖指标 大盘指标。 输出超买超卖指标:上涨家数-下跌家数的N日异同移动平均 输出MAOBOS:OBOS的M日简单移动平均 1.指标上升至80时为超买&…

第2章 数据结构中栈与队列的概念

文章目录文档配套视频讲解链接地址第02 章 栈与队列2.1 栈与队列的框图2.2 栈1. 栈的概念2. 顺序栈3. 实例11 顺序栈4. 实例12 链式栈2.3 队列1. 队列的概念2. 顺序队列3. 实例13 顺序队列4. 链式队列5. 实例14 链式队列2.4 实例15 球钟问题2.5 队列与栈的转换1. 实例16 顺序的…

基于Labview的图像傅里叶变换研究-含Labview程序

⭕⭕ 目 录 ⭕⭕一、说明二、基于Labview的图像傅里叶变换研究三、Labview源程序下载一、说明 订阅该专栏后&#xff0c;可获取该专栏内的任意一份代码&#xff0c;请及时私信博主获取下载链接。 从该专栏获取的程序&#xff0c;博主有责任并将保证该程序能在您电脑上完整运行…

初识Spring框架~控制反转IoC、依赖注入DI以及Spring项目的创建方式

目录 Spring框架初识 Spring IoC IoC(控制反转) DI(依赖注入) Spring项目的创建 创建一个maven项目 配置XML文件 添加启动类 简单了解Bean对象的存储与获取 创建一个Spring IoC容器 注册Bean对象 获取并使用Bean对象 Spring框架初识 通常所说的Spring是指Spri…

java知识梳理 第十五章 I/O流

一、文件 1.1 文件流 值得一提的是&#xff0c;这里的流的概念是围绕java程序展开的 1.2 常用的文件操作 1.2.1 创建文件对象相关构造器和方法 代码演示如上&#xff0c;读者可自行实验 1.2.2 获取文件的相关信息 代码演示如上&#xff0c;读者可自行实验 1.2.3 目录的操作和删…

NodeJs实战-待办列表(6)-前端绘制表格显示待办事项详情

NodeJs实战-待办列表6-前端绘制表格显示待办事项详情定义服务器返回的 json 数据前端绘制动态表格后端返回列表数据验证执行添加查看数据库中的数据是否与页面一致使用浏览器debug表格绘制过程项目地址前面几节显示的列表&#xff0c;看不到事项创建时间&#xff0c;完成时间&a…

springmvc-day03

springmvc-day03 第一章 拦截器 1.概念 1.1 使用场景 1.1.1 生活中坐地铁的场景 为了提高乘车效率&#xff0c;在乘客进入站台前统一检票&#xff1a; 1.1.2 程序中的校验登录场景 在程序中&#xff0c;使用拦截器在请求到达具体 handler 方法前&#xff0c;统一执行检…

基于stm32单片机的智能恒温自动加氧换水鱼缸

资料编号&#xff1a;105 下面是相关功能视频演示&#xff1a; 105-基于stm32单片机的智能恒温自动加氧换水鱼缸Proteus仿真&#xff08;源码仿真全套资料&#xff09;功能讲解&#xff1a;采用stm32单片机&#xff0c;ds18b20测量温度&#xff0c;LCD1602显示温度&#xff0c…

C语言第十一课(上):编写扫雷游戏(综合练习2)

目录 前言&#xff1a; 一、文件建立&#xff1a; 1.头文件game.h&#xff1a; 2.函数定义文件game.c&#xff1a; 3.工程测试文件test.c&#xff1a; 二、编写井字棋游戏&#xff1a; 1.程序整体执行思路&#xff1a; 2.menu菜单&#xff1a; 3.game游戏函数逻辑&#xff…

【Detectron2】代码库学习-5.标注格式- 矩形框, 旋转框,关键点, mask, 实例标注,IOU计算, 旋转框IOU计算,

文章目录Detectron2 内置的标注格式BoxMode 表示方式实用APIRotatedBoxesInstances 实例标注KeypointsMasks结语Detectron2 内置的标注格式 BoxesRotatedBoxesBitMasksPolygonMasksROIMasksKeypointsInstancesImageList BoxMode 表示方式 XYXY_ABSXYWH_ABSXYXY_REL # 相对模…