SpringBoot3整合Elasticsearch8.x之全面保姆级教程

news2025/2/27 13:59:19

整合ES

环境准备

  1. 安装配置EShttps://blog.csdn.net/qq_50864152/article/details/136724528
  2. 安装配置Kibanahttps://blog.csdn.net/qq_50864152/article/details/136727707
  3. 新建项目:新建名为webSpringBoot3项目

elasticsearch-java

公共配置

  1. 介绍:一个开源的高扩展的分布式全文检索引擎,可以近乎实时的存储 和检索数据
  2. 依赖:web模块引入elasticsearch-java依赖---但其版本必须与你下载的ES的版本一致
<!-- 若不存在Spring Data ES的某个版本支持你下的ES版本,则使用  -->
<!-- ES 官方提供的在JAVA环境使用的依赖 -->
<dependency>
  <groupId>co.elastic.clients</groupId>
  <artifactId>elasticsearch-java</artifactId>
  <version>8.11.1</version>
</dependency>

<!-- 和第一个依赖是一起的,为了解决springboot项目的兼容性问题  -->
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
</dependency>
  1. 配置:web模块dev目录application-dal添加

使用open+@Value("${elasticsearch.open}")的方式不能放到Nacos配置中心

# elasticsearch配置
elasticsearch:
  # 自定义属性---设置是否开启ES,false表不开窍ES
  open: true
  # es集群名称,如果下载es设置了集群名称,则使用配置的集群名称
  clusterName: es
  hosts: 127.0.0.1:9200
  # es 请求方式
  scheme: http
  # es 连接超时时间
  connectTimeOut: 1000
  # es socket 连接超时时间
  socketTimeOut: 30000
  # es 请求超时时间
  connectionRequestTimeOut: 500
  # es 最大连接数
  maxConnectNum: 100
  # es 每个路由的最大连接数
  maxConnectNumPerRoute: 100
  1. 配置:web模块config包下新建ElasticSearchConfig
package cn.bytewisehub.pai.web.config;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.ElasticsearchTransport;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Data
@Configuration
@ConfigurationProperties(prefix = "elasticsearch")
public class ElasticSearchConfig {

    // 是否开启ES
    private Boolean open;

    // es 集群host ip 地址
    private String hosts;

    // es用户名
    private String userName;

    // es密码
    private String password;

    // es 请求方式
    private String scheme;

    // es集群名称
    private String clusterName;

    // es 连接超时时间
    private int connectTimeOut;

    // es socket 连接超时时间
    private int socketTimeOut;

    // es 请求超时时间
    private int connectionRequestTimeOut;

    // es 最大连接数
    private int maxConnectNum;

    // es 每个路由的最大连接数
    private int maxConnectNumPerRoute;

    // es api key
    private String apiKey;


    public RestClientBuilder creatBaseConfBuilder(String scheme){


        // 1. 单节点ES Host获取
        String host = hosts.split(":")[0];
        String port = hosts.split(":")[1];
        // The value of the schemes attribute used by noSafeRestClient() is http
        // but The value of the schemes attribute used by safeRestClient() is https
        HttpHost httpHost = new HttpHost(host, Integer.parseInt(port),scheme);

        // 2. 创建构建器对象
        //RestClientBuilder: ES客户端库的构建器接口,用于构建RestClient实例;允许你配置与Elasticsearch集群的连接,设置请求超时,设置身份验证,配置代理等
        RestClientBuilder builder = RestClient.builder(httpHost);

        // 连接延时配置
        builder.setRequestConfigCallback(requestConfigBuilder -> {
            requestConfigBuilder.setConnectTimeout(connectTimeOut);
            requestConfigBuilder.setSocketTimeout(socketTimeOut);
            requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeOut);
            return requestConfigBuilder;
        });

        // 3. HttpClient 连接数配置
        builder.setHttpClientConfigCallback(httpClientBuilder -> {
            httpClientBuilder.setMaxConnTotal(maxConnectNum);
            httpClientBuilder.setMaxConnPerRoute(maxConnectNumPerRoute);
            return httpClientBuilder;
        });

        return builder;
    }
}
  1. 测试:web模块test目录下新建ElasticSearchTest
@Slf4j
@SpringBootTest
public class ElasticSearchTest {

    @Value("${elasticsearch.open}")
    // 是否开启ES,默认开启
    String open = "true";
}

直接连接ES

  1. 设置:ES Elasticsearch.ymlxpack.security.enabled属性设置为false

xpack.security.enabled
● 默认true:必须使用账号连接ES
● 若为false:必须使用http://localhost:9200/访问ES服务+启动Kibana服务会失败+不需要使用账号连接,但必须使用HTTP连接

  1. 添加:ElasticSearchConfig类添加下列方法
/**
* @function: 创建使用http连接来直接连接ES服务器的客户端
* 如果@Bean没有指定bean的名称,那么这个bean的名称就是方法名
*/
@Bean(name = "directConnectionESClient")
public ElasticsearchClient directConnectionESClient(){

    RestClientBuilder builder = creatBaseConfBuilder((scheme == "http")?"http":"http");
    
    //Create the transport with a Jackson mapper
    ElasticsearchTransport transport = new RestClientTransport(builder.build(), new JacksonJsonpMapper());

    //And create the API client
    ElasticsearchClient esClient = new ElasticsearchClient(transport);

    return esClient;
};
  1. 添加:ElasticSearchTest类中添加下列代码---索引名必须小写
  2. 运行:设置跳过测试--->手动运行/不跳过--->直接install,但不运行测试
@Resource(name = "directConnectionESClient")
ElasticsearchClient directConnectionESClient;


@Test
public void directConnectionTest() throws IOException {

if (open.equals("true")) {
    //创建索引
    CreateIndexResponse response = directConnectionESClient.indices().create(c -> c.index("direct_connection_index"));
    log.info(response.toString());
}
else{
    log.info("es is closed");
}
}

账号密码连接ES

  1. 设置:ES Elasticsearch.ymlxpack.security.enabled属性使用默认值+ xpack.security.http.ssl.enabled设置为false

注意:若xpack.security.enabled属性为false,则xpack.security.http.ssl.enabled属性不生效,即相当于设置为false;所有以xpack开头的属性都不会生效

ES Elasticsearch.ymlxpack.security.http.ssl.enabled
● 默认true:必须使用https://localhost:9200/访问ES服务+启动Kibana服务会成功+需要使用账号连接+必须使用HTTPS连接
● 若为false:必须使用http://localhost:9200/访问ES服务+启动Kibana服务会失败+需要使用账号连接,但必须使用HTTP连接

  1. 配置:dev目录application-dal中添加下列配置
# elasticsearch配置
elasticsearch:
  userName:  #自己的账号名
  password:  #自己的密码
  1. 添加:ElasticSearchTest类中添加下列代码---索引名必须小写+不能有空格
  2. 运行:设置跳过测试--->手动运行/不跳过--->直接install,但不运行测试
@Resource(name = "accountConnectionESClient")
ElasticsearchClient accountConnectionESClient;


@Test
public void accountConnectionTest() throws IOException {

if (open.equals("true")) {
    //创建索引
    CreateIndexResponse response = accountConnectionESClient.indices().create(c -> c.index("account_connection_index"));
    log.info(response.toString());
}
else{
    log.info("es is closed");
}
}

证书账号连接ES

  1. 设置:ES Elasticsearch.ymlxpack.security.enabledxpack.security.http.ssl.enabled配置项使用默认值

设置为true后,ES就走https,若schemehttp,则报Unrecognized SSL message错误

  1. 配置:将dev目录application-dalelasticsearch.scheme配置项改成https
  2. 证书添加:终端输入keytool -importcert -alias es_https_ca -keystore "D:\computelTool\Java\JDK\JDK21\lib\security\cacerts" -file "D:\computelTool\database\elasticsearch8111\config\certs\http_ca.crt"

keytool -delete -alias es_https_ca -keystore "D:\computelTool\Java\JDK\JDK21\lib\security\cacerts" ---与上面的命令相反

  1. 拷贝:将ESconfig目录下certs目录下的http_ca.crt文件拷贝到web模块resource目录
  2. 添加:ElasticSearchConfig类添加下列方法
/**
* @function: 创建用于安全连接(证书 + 账号)ES服务器的客户端
* 如果@Bean没有指定bean的名称,那么这个bean的名称就是方法名
*/
@Bean(name = "accountAndCertificateConnectionESClient")
public ElasticsearchClient accountAndCertificateConnectionESClient() {


    RestClientBuilder builder = creatBaseConfBuilder( (scheme == "https")?"https":"https");

    // 1.账号密码的配置
    //CredentialsProvider: 用于提供 HTTP 身份验证凭据的接口; 允许你配置用户名和密码,以便在与服务器建立连接时进行身份验证
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));

    // 2.设置自签证书,并且还包含了账号密码
    builder.setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder
                                        .setSSLContext(buildSSLContext())
                                        .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
                                        .setDefaultCredentialsProvider(credentialsProvider));

    RestClientTransport transport = new RestClientTransport(builder.build(), new JacksonJsonpMapper());

    //And create the API client
    ElasticsearchClient esClient = new ElasticsearchClient(transport);

    return esClient;
}

private static SSLContext buildSSLContext() {

    // 读取http_ca.crt证书
    ClassPathResource resource = new ClassPathResource("http_ca.crt");
    SSLContext sslContext = null;
    try {
        // 证书工厂
        CertificateFactory factory = CertificateFactory.getInstance("X.509");
        Certificate trustedCa;
        try (InputStream is = resource.getInputStream()) {
            trustedCa = factory.generateCertificate(is);
        }
        // 密钥库
        KeyStore trustStore = KeyStore.getInstance("pkcs12");
        trustStore.load(null, "liuxiansheng".toCharArray());
        trustStore.setCertificateEntry("ca", trustedCa);
        SSLContextBuilder sslContextBuilder = SSLContexts.custom()
                 .loadTrustMaterial(trustStore, null);
        sslContext = sslContextBuilder.build();
    } catch (CertificateException | IOException | KeyStoreException | NoSuchAlgorithmException |
                 KeyManagementException e) {
        log.error("ES连接认证失败", e);
    }
    return sslContext;
}

  1. 测试:ElasticSearchTest类添加
@Resource(name = "accountAndCertificateConnectionESClient")
ElasticsearchClient accountAndCertificateConnectionESClient;

@Test
public void  accountAndCertificateConnectionTest() throws IOException {

if (open.equals("true")) {
    //创建索引
    CreateIndexResponse response =  accountAndCertificateConnectionESClient.indices().create(c -> c.index("account_and_certificate_connection_index"));
    log.info(response.toString());
    System.out.println(response.toString());
}
else{
    log.info("es is closed");
}
}

Spring Data ES

公共配置

  1. 依赖:web模块引入该依赖---但其版本必须与你下载的ES的版本一致

版本:点击https://spring.io/projects/spring-data-elasticsearch#learn,点击GA版本的Reference Doc,点击version查看Spring Data ESES版本的支持关系

参考:https://www.yuque.com/itwanger/vn4p17/wslq2t/https://blog.csdn.net/qq_40885085/article/details/105023026

<!-- 若存在Spring Data ES的某个版本支持你下的ES版本,则使用  -->
<!-- Spring官方在ES官方提供的JAVA环境使用的依赖的基础上做了封装 -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

<!-- ESTestEntity用到 -->
<dependency>
	<groupId>jakarta.servlet</groupId>
	<artifactId>jakarta.servlet-api</artifactId>
	<version>6.0.0</version>
	<scope>provided</scope>
</dependency>

<!-- ESTestEntity用到 -->
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <scope>provided</scope>
  <!--provided:指定该依赖项在编译时是必需的,才会生效, 但在运行时不需要,也不会生效-->
  <!--这样 Lombok 会在编译期静悄悄地将带 Lombok 注解的源码文件正确编译为完整的 class 文件 -->
</dependency>
  1. 新建:web模块TestEntity目录新建ESTestEntity
@Data
@EqualsAndHashCode(callSuper = false)
@Document(indexName = "test")
public class ESTestEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    private Long id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String content;

    private String title;

    private String excerpt;
}
  1. 新建:web模块TestRepository包下新建ESTestRepository 接口
import cn.bytewisehub.pai.web.TestEntity.ESTestEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface ESTestRepository extends ElasticsearchRepository<ESTestEntity, Long> {
}

直接连接ES

  1. 配置:ES Elasticsearch.ymlxpack.security.enabled属性设置为false

xpack.security.enabled
● 默认true:必须使用账号连接ES
● 若为false:必须使用http://localhost:9200/访问ES服务+启动Kibana服务会失败+不需要使用账号连接,但必须使用HTTP连接

  1. 配置:web模块dev目录application-dal添加
spring:
  elasticsearch:
    uris:
      - http://127.0.0.1:9200
  1. 新建:web模块test目录新建ElasticsearchTemplateTest
import cn.bytewisehub.pai.web.TestEntity.ESTestEntity;
import cn.bytewisehub.pai.web.TestRepository.ESTestRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;

@SpringBootTest
public class ElasticsearchTemplateTest {

    @Autowired
    ESTestRepository esTestRepository;

    @Autowired
    ElasticsearchTemplate elasticsearchTemplate;

    @Test
    void save() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(1L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(elasticsearchTemplate.save(esTestEntity));
    }

    @Test
    void insert() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(2L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(esTestRepository.save(esTestEntity));
    }
}
  1. 访问:点击http://localhost:9200/test/_search ---查询索引库test
    请添加图片描述

HTTP连接ES

  1. 配置:ES Elasticsearch.ymlxpack.security.enabled属性使用默认值+ xpack.security.http.ssl.enabled设置为false

ES Elasticsearch.ymlxpack.security.http.ssl.enabled
● 默认true:必须使用https://localhost:9200/访问ES服务+启动Kibana服务会成功+需要使用账号连接+必须使用HTTPS连接
● 若为false:必须使用http://localhost:9200/访问ES服务+启动Kibana服务会失败+需要使用账号连接,但必须使用HTTP连接

  1. 配置:web模块dev目录application-dal添加
spring:
  elasticsearch:
    uris:
      - http://127.0.0.1:9200
    username:  # 账号用户名
    password:  #账号密码
  1. 修改:web模块test目录下ElasticsearchTemplateTest修改成这样,其他参见直接连接
import cn.bytewisehub.pai.web.TestEntity.ESTestEntity;
import cn.bytewisehub.pai.web.TestRepository.ESTestRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;

@SpringBootTest
public class ElasticsearchTemplateTest {

    @Autowired
    ESTestRepository esTestRepository;

    @Autowired
    ElasticsearchTemplate elasticsearchTemplate;

    @Test
    void save() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(1L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(elasticsearchTemplate.save(esTestEntity));
    }

    @Test
    void insert() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(2L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(esTestRepository.save(esTestEntity));
    }
}
  1. 访问:点击http://localhost:9200/test/_search ---查询索引库test

HTTPS连接ES

  1. 配置:ES Elasticsearch.ymlxpack.security.enabledxpack.security.http.ssl.enabled属性使用默认值
  2. 配置:web模块dev目录application-dal添加
spring:
  elasticsearch:
    uris:
      - https://127.0.0.1:9200
    username:  # 账号用户名
    password:  #账号密码
  1. 修改:web模块test目录下ElasticsearchTemplateTest修改成这样,其他参见直接连接
import cn.bytewisehub.pai.web.TestEntity.ESTestEntity;
import cn.bytewisehub.pai.web.TestRepository.ESTestRepository;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;

@SpringBootTest
public class ElasticsearchTemplateTest {

    @Autowired
    ESTestRepository esTestRepository;

    @Autowired
    ElasticsearchTemplate elasticsearchTemplate;

    @Test
    void save() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(1L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(elasticsearchTemplate.save(esTestEntity));
    }

    @Test
    void insert() {
        ESTestEntity esTestEntity = new ESTestEntity();
        esTestEntity.setId(2L);
        esTestEntity.setContent("不安全连接");
        esTestEntity.setTitle("world");
        esTestEntity.setExcerpt("test");
        System.out.println(esTestRepository.save(esTestEntity));
    }
}
  1. 访问:点击http://localhost:9200/test/_search ---查询索引库test

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

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

相关文章

Xilinx LVDS ISERDESE2

ISERDESE2 7 系列 FPGA 是一款专用的串行到并行转换器,具有特定的时钟和逻辑功能,旨在促进高速源同步应用的实现。该ISERDESE2避免了在FPGA架构中设计解串器时遇到的额外时序复杂性. ISERDESE2功能包括: 1,专用解串器/串行转换器 ISERDESE2解串器可实现高速数据传输,而无需…

C语言 实用调试技巧

我们的博客已经更新到了数据结构&#xff0c;但是当我在深耕数据结构时我发现我在C语言是遗漏了一个重要的东西&#xff0c;那就是C语言的使用调试技巧。这篇博客对数据结构非常重要&#xff0c;请大家耐心观看。 1. 什么是bug&#xff1f; 第一次被发现的导致计算机错误的飞蛾…

TCPIP协议总结

一、TCP的三次握手 TCP连接的建立时&#xff0c;双方需要经过三次握手&#xff0c;而断开连接时&#xff0c;双方需要经过四次分手&#xff0c;那么&#xff0c;其三次握手和四次分手分别做了什么呢&#xff1f;又是如何进行的呢&#xff1f; 通常情况下&#xff0c;建立连接的…

数据可视化看板的进阶之路:山海鲸可视化私有化部署体验

作为一名长期使用山海鲸可视化的资深用户&#xff0c;我在数据可视化看板的制作过程中&#xff0c;深刻感受到了这款软件带来的便捷与高效。今天&#xff0c;我想与大家分享一些我在使用山海鲸可视化制作数据可视化看板时的经验&#xff0c;给对这款产品同样感兴趣的朋友同行一…

使用ansible剧本进行lvm分盘

使用 Ansible 剧本&#xff08;Playbook&#xff09;进行 LVM 分区管理是一种自动化的方式&#xff0c;可以帮助管理员在多台主机上批量管理逻辑卷。 部署环境 3台主机&#xff0c;添加硬盘 ansible-galaxy collection install community.general 联网执行&#xff0c;下…

高防服务器秒解是什么意思

高防服务器秒解是指高防服务器在遭受大规模的DDoS攻击时&#xff0c;能够迅速解决问题或应对攻击。DDoS攻击是指攻击者通过向目标服务器发送大量的请求&#xff0c;使服务器资源耗尽或无法正常响应其他合法用户的请求&#xff0c;从而导致服务不可用。高防服务器通过具备高性能…

SLAM算法与工程实践——CMake使用(1)

SLAM算法与工程实践系列文章 下面是SLAM算法与工程实践系列文章的总链接&#xff0c;本人发表这个系列的文章链接均收录于此 SLAM算法与工程实践系列文章链接 下面是专栏地址&#xff1a; SLAM算法与工程实践系列专栏 文章目录 SLAM算法与工程实践系列文章SLAM算法与工程实践…

【vue】深入探讨vue中组件间多种传值方式

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

直流调速器DCS800-S02-0260-05模块DCS800S02026005

型号代码&#xff1a;DCS800-S02-0260-05 电压&#xff1a;525V&#xff1b; 电流&#xff1a;350A&#xff1b; 双桥&#xff1b; 重量&#xff1a;25公斤&#xff1b; 定制&#xff1a;否 最小起订量&#xff1a;1 件 产品名称&#xff1a;DCS800直流调速模块 产品净深/长度&…

Kotlin: 协程的四种启动模式(CoroutineStart)

点击查看CoroutineStart英文文档 创建协程的三种方式 runBlocking 运行一个协程并且会阻塞当前线程&#xff0c;直到它完成。launch 启动一个新的协程&#xff0c;不会阻塞当前线程&#xff0c;并且返回一个Job&#xff0c;可以取消。async async和await是两个函数&#xff0c…

【CSPP】2021-04-2 邻域均值 经典二维前缀和

2021-04-2 邻域均值 经典二维前缀和 索引2021-04-2 邻域均值 经典二维前缀和思路遇到的问题完整代码 索引 历年CSP认证考试真题题解总汇持续更新 2021-04-2 邻域均值 经典二维前缀和 这题算是第二题中简单的那种了&#xff0c;但是我还是写了接近40分钟才AC&#xff0c;写二…

HTML静态网页成品作业(HTML+CSS)——世博园介绍(2个页面)

&#x1f389;不定期分享源码&#xff0c;关注不丢失哦 文章目录 一、作品介绍二、作品演示三、代码目录四、网站代码HTML部分代码 五、源码获取 一、作品介绍 &#x1f3f7;️本套采用HTMLCSS&#xff0c;未使用Javacsript代码&#xff0c;共有2个页面。 二、作品演示 三、代…

四.流程控制(顺序,分支,循环,嵌套)

c刚刚转过来的记得写在public static void main&#xff08;String[] args&#xff09;的花括号里 一.顺序结构 二.分支结构 if &#xff0c;switch 1.if (条件判断&#xff09; 2.if else 3.if else if else if ... else(它是一个一个否定来一个个执行判断的 4.s…

torchvision pytorch预训练模型目标检测使用

参考&#xff1a; https://pytorch.org/vision/0.13/models.html https://blog.csdn.net/weixin_42357472/article/details/131747022 有分类、检测、分割相关预训练模型 1、目标检测 https://pytorch.org/vision/0.13/models.html#object-detection-instance-segmentation-…

Springboot笔记-03

1.properties配置文件 #配制oerson的值 person.lastname张三 person.age12 person.birth2017/12/12 person.bossfalse person.dog.namedag person.dog.age15 person.maps.k1v1 person.maps.k212 person.listsa,b,c运行结果乱码 因为idea默认是utf-8编码而properties是ascall编…

禅道二次开发——创建需求

获取Token 官网参考 https://www.zentao.net/book/api/setting-369.html post http://xxx:8442/zentaopms/www/api.php/v1/tokensbody {"account": "xxx", "password": "xxx"}结果如下图 创建需求 官网参考 https://www.zentao.…

一文掌握:Gitlab的完整使用手册

&#x1f413;序言 GitLab是一个强大的版本控制和协作平台&#xff0c;用于管理代码仓库、项目、问题跟踪、持续集成和部署等软件开发任务。可以做一些创建项目、添加成员、管理代码、问题跟踪和持续集成等方面功能。 &#x1f413;创建Gitlab账户 如果你还没有GitLab账户&…

如何正确理解和区分承诺型OKR与愿景型OKR?

在目标管理的实践中&#xff0c;OKR&#xff08;Objectives and Key Results&#xff09;工作法作为一种高效的目标设定与跟踪工具&#xff0c;得到了广泛的应用。然而&#xff0c;OKR并非一种固定的模式&#xff0c;它可以根据企业的战略需求和文化背景进行灵活调整。其中&…

npm i安装依赖报错,但是cnpm i 却安装成功

问题描述&#xff1a;在a项目中npm i 安装依赖时发生以上报错&#xff0c;但是cnpm i 却成功&#xff0c;而且在其他项目中npm i 安装其他项目依赖也能成功.... 解决办法&#xff1a;删除项目中package-lock.json文件后再npm i 即可

Linux系统——数据库Mysql

目录 一、数据库原理 1.数据的时代 2.数据的分类 3.数据库的发展史 3.1文件管理系统的缺点 3.2数据库系统发展阶段 4. 数据库的基本概念 4.1数据 4.2表 4.3数据库 5.DBMS——数据库管理系统 5.1数据库管理系统的优点 5.2数据库管理系统的基本功能 5.3数据库管理系…