K8S - 理解volumeMounts 中的subpath

news2024/9/24 7:23:24

在上一篇文章中
springboot service如何动态读取外部配置文件

介绍了springboot 中如何实时读取外部配置文件的内容



部署在K8S

接下来我把它部署在k8s



首先, 我们把配置文件放入项目某个目录

这步部是必须的, 毕竟我们要引入是项目外部的文件, 这一步只是方便在不同CICD 环境下的docker 构建
我们就放在 src 外面的configs folder
在这里插入图片描述


修改docker file

# use the basic openjdk image
FROM openjdk:17

# setup working directory
WORKDIR /app

# create /app/config
RUN mkdir -p /app/config/config2

# copy configs files from project folder to /app/config
# When using COPY with more than one source file, the destination must be a directory and end with a /
COPY configs/external-config.properties /app/config/
COPY configs/external-config2.properties /app/config/config2/

# copy and rename jar file into container
COPY target/*.jar app.jar

# expose port
EXPOSE 8080

# define environment variable, and provide a default value
ENV APP_ENVIRONMENT=dev

# define the default startup command, it could be overridden in k8s
# CMD java -jar -Dserver.port=8080 -Dspring.config.name=application-${APP_ENVIRONMENT} app.jar
CMD java -jar -Dserver.port=8080 app.jar --spring.profiles.active=${APP_ENVIRONMENT}

需要创建/app/configs 并把配置文件复制到这里, 因为springboot service 会从这个path读取
注意有两个config 文件, 他们并不在同1个folder
external-config2.properties 在subfolder config2里面



构建镜像和部署镜像到GAR

这一步我们用google cloudbuild 完成
至于cloudbuild 的介绍请参考
初探 Google 云原生的CICD - CloudBuild

cloudbuild-gcr.yaml

# just to update the docker image to GAR with the pom.xml version

steps:
  - id: run maven install
    name: maven:3.9.6-sapmachine-17 # https://hub.docker.com/_/maven
    entrypoint: bash
    args:
      - '-c'
      - |
        whoami
        set -x
        pwd
        mvn install
        cat pom.xml | grep -m 1 "<version>" | sed -e 's/.*<version>\([^<]*\)<\/version>.*/\1/' > /workspace/version.txt
        echo "Version: $(cat /workspace/version.txt)"


  - id: build and push docker image
    name: 'gcr.io/cloud-builders/docker'
    entrypoint: bash
    args:
      - '-c'
      - |
        set -x
        echo "Building docker image with tag: $(cat /workspace/version.txt)"
        docker build -t $_GAR_BASE/$PROJECT_ID/$_DOCKER_REPO_NAME/${_APP_NAME}:$(cat /workspace/version.txt) .
        docker push $_GAR_BASE/$PROJECT_ID/$_DOCKER_REPO_NAME/${_APP_NAME}:$(cat /workspace/version.txt)


logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#options
  logging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging



substitutions:
  _DOCKER_REPO_NAME: my-docker-repo
  _APP_NAME: cloud-order
  _GAR_BASE: europe-west2-docker.pkg.dev

部署完成后, 我们得到1个gar的对应image的url
europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0



编写k8s yaml 和部署到k8s

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0 # image of the container
        imagePullPolicy: Always
        name: container-cloud-order
        command: ["bash"]
        args: 
          - "-c"
          - |
            java -jar -Dserver.port=8080 app.jar --spring.profiles.active=$APP_ENVIRONMENT
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
            
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

没什么特别

部署:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f deployment-cloud-order-with-subpath.yaml 
deployment.apps/deployment-cloud-order created
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl get pods
NAME                                         READY   STATUS      RESTARTS       AGE
deployment-bq-api-service-6f6ffc7866-8djx9   1/1     Running     3 (12d ago)    17d
deployment-bq-api-service-6f6ffc7866-g4854   1/1     Running     12 (12d ago)   61d
deployment-bq-api-service-6f6ffc7866-lwxt7   1/1     Running     14 (12d ago)   63d
deployment-bq-api-service-6f6ffc7866-mxwcq   1/1     Running     11 (12d ago)   61d
deployment-cloud-order-58ddcf894d-8pjsz      1/1     Running     0              5s
deployment-cloud-order-58ddcf894d-mp4js      1/1     Running     0              5s
deployment-cloud-order-58ddcf894d-sszjd      1/1     Running     0              5s

检查容器内的配置文件:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-58ddcf894d-8pjsz -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2.properties
bash-4.4# 



测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1842    0  1842    0     0   1827      0 --:--:--  0:00:01 --:--:--  1829
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-58ddcf894d-8pjsz",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2",
  }
}

注意 customConfig1 和 customConfig2 的值, 部署是成功的



For customConfig2 使用configMap

由于customConfig2 是实时更新的
我们尝试用configmap 来取代 上面external-config2.properties 的配置
注意这里的值改成 value of config2 - from k8s configmap 方便区分



构建1个external-config2 的configmap 资源对象

configmap-cloud-order-external-config2.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-cloud-order-external-config2
data:
  external.custom.config2: external.custom.config2=value of config2 - from k8s configmap

部署:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f configmap-cloud-order-external-config2.yaml 
configmap/configmap-cloud-order-external-config2 created
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl describe cm configmap-cloud-order-external-config2
Name:         configmap-cloud-order-external-config2
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
external.custom.config2:
----
external.custom.config2=value of config2 - from k8s configmap

BinaryData
====

Events:  <none>



修改deployment yaml 引入configmap

apiVersion: apps/v1
kind: Deployment
metadata:
  labels: # label of this deployment
    app: cloud-order # custom defined
    author: nvd11
  name: deployment-cloud-order # name of this deployment
  namespace: default
spec:
  replicas: 3            # desired replica count, Please note that the replica Pods in a Deployment are typically distributed across multiple nodes.
  revisionHistoryLimit: 10 # The number of old ReplicaSets to retain to allow rollback
  selector: # label of the Pod that the Deployment is managing,, it's mandatory, without it , we will get this error 
            # error: error validating data: ValidationError(Deployment.spec.selector): missing required field "matchLabels" in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector ..
    matchLabels:
      app: cloud-order
  strategy: # Strategy of upodate
    type: RollingUpdate # RollingUpdate or Recreate
    rollingUpdate:
      maxSurge: 25% # The maximum number of Pods that can be created over the desired number of Pods during the update
      maxUnavailable: 25% # The maximum number of Pods that can be unavailable during the update
  template: # Pod template
    metadata:
      labels:
        app: cloud-order # label of the Pod that the Deployment is managing. must match the selector, otherwise, will get the error Invalid value: map[string]string{"app":"bq-api-xxx"}: `selector` does not match template `labels`
    spec: # specification of the Pod
      containers:
      - image: europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/cloud-order:1.1.0 # image of the container
        imagePullPolicy: Always
        name: container-cloud-order
        command: ["bash"]
        args: 
          - "-c"
          - |
            java -jar -Dserver.port=8080 app.jar --spring.profiles.active=$APP_ENVIRONMENT
        env: # set env varaibles
        - name: APP_ENVIRONMENT # name of the environment variable
          value: prod # value of the environment variable
        volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2.properties # name of the file to be mounted
            
            
      restartPolicy: Always # Restart policy for all containers within the Pod
      terminationGracePeriodSeconds: 10 # The period of time in seconds given to the Pod to terminate gracefully

注意这里使用了 volume 和 volumemount



重新部署 cloud-order service

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl delete deploy deployment-cloud-order
deployment.apps "deployment-cloud-order" deleted
gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f deployment-cloud-order-with-subpath.yaml 
deployment.apps/deployment-cloud-order created



测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1863    0  1863    0     0   3888      0 --:--:-- --:--:-- --:--:--  3889
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-69d4cd76d6-hwtfj",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2 - from k8s configmap",

并没什么大问题, 证明configmap 的配置是可以覆盖docker里面定义的配置文件的



实时修改configmap 的配置

这时我们修改一下 configmap configmap-cloud-order-external-config2 里的值
由 external.custom.config2: external.custom.config2=value of config2 - from k8s configmap
改成 external.custom.config2: external.custom.config2=value of config2 - from k8s configmap updated!

apiVersion: v1
kind: ConfigMap
metadata:
  name: configmap-cloud-order-external-config2
data:
  external.custom.config2: external.custom.config2=value of config2 - from k8s configmap updated!

更新:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl apply -f configmap-cloud-order-external-config2.yaml 
configmap/configmap-cloud-order-external-config2 configured

等半分钟后 (1是 k8s 需要时间把 configmap的值刷新到 pods里的volumes, 2时是springboot本身需要定时器去重新获取值)
再测试api

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1872    0  1872    0     0   3900      0 --:--:-- --:--:-- --:--:--  3900
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-69d4cd76d6-qj98f",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "value of config2 - from k8s configmap updated!",

果然customConfig2的值自动更新了, 正是我们想要的
而且容器里的文件也的确更新了

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-69d4cd76d6-hwtfj -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls config
config2  external-config.properties
bash-4.4# cat config/config2/external-config2.properties 
external.custom.config2=value of config2 - from k8s configmap updated!



volumes mount 会覆盖整个文件夹(其他文件被删除)

下面来点整活
我们修改一下deployment 的yaml 配置, 把configmap的值 mark成另1个文件名

  volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2-1.properties # name of the file to be mounted

按照设想, 容器内的configmap里的
/app/config/config2/ 文件内将会有两个文件

dockerfile 定义的external-config2.properties
和 k8s 定义的 external-config2-1.properties

实际部署测试:

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ curl http://www.jp-gcp-vms.cloud:8085/cloud-order/actuator/info | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1837    0  1837    0     0    926      0 --:--:--  0:00:01 --:--:--   926
{
  "app": "Cloud Order Service",
  "appEnvProfile": "prod",
  "version": "1.1.0",
  "hostname": "deployment-cloud-order-6878b85d44-cdvlc",
  "dbUrl": "jdbc:mysql://192.168.0.42:3306/demo_cloud_order?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true",
  "description": "This is a simple Spring Boot application to for cloud order...",
  "customConfig1": "value of config1",
  "customConfig2": "not defined",

customConfig2 居然是not defined
检查容器
发现 external-config2.properties 没了

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-6878b85d44-cdvlc -- /bin/bash
bash-4.4# ls
app.jar  config
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2-1.properties
bash-4.4# 

原因是 当k8s 把 volume volume-external-config2 mount在 /app/config/config2 中的时候, 原来的文件就会消失



尝试把新文件mount到1个subfolder

解决方法1:
把 volume volume-external-config2 mount在 /app/config/config2/config-sub
应该可以解决

我们修改deployment yaml

  volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/config-sub
	    volumes:
	      - name: volume-external-config2
	        configMap:
	          name: configmap-cloud-order-external-config2
	          items:
	            - key: external.custom.config2
	              path: external-config2-1.properties # name of the file to be mounted

mountPath 改成了/app/config/config2/config-sub

这种方法是可行的

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-654974f855-cmdz7 -- /bin/bash
bash-4.4# ls
app.jar  config
bash-4.4# cd config
bash-4.4# ls
config2  external-config.properties
bash-4.4# cd config2
bash-4.4# ls
config-sub  external-config2.properties
bash-4.4# cd config-sub
bash-4.4# ls
external-config2-1.properties
bash-4.4# 

而且证明了, mountpath中的路径不存在的话, k8s会尝试创建。



利用subpath 去把文件mount在同样的folder

但是上面的做法, 能把新文件mount在1个字母中, 的确不会另旧文件消失,但是并直接真正解决问题

K8S 提供了subpath 的方法:
我们修改deployment yaml

        volumeMounts:
          - name: volume-external-config2
            mountPath: /app/config/config2/external-config2-1.properties # if we need to use subpath, need to provide the filename as well
            subPath: external-config2-1.properties # name of the file to be mounted, if we use subpath, the other files in that same folder will not dispear
      volumes:
        - name: volume-external-config2
          configMap:
            name: configmap-cloud-order-external-config2
            items:
              - key: external.custom.config2
                path: external-config2-1.properties # name of the file to be mounted                                                               

注意这里有两个改动:

  1. mountpath 上加上了文件名
  2. 添加subpath 配置, 其值还是文件名

这次的确能令两个配置文件同时存在, 原来的文件external-config2.properties 并没有被抹除

gateman@MoreFine-S500:~/projects/coding/k8s-s/service-case/cloud-order$ kubectl exec -it deployment-cloud-order-7775b8c7cd-jnv7v -- /bin/bash
bash-4.4# pwd
/app
bash-4.4# ls
app.jar  config
bash-4.4# ls config
config2  external-config.properties
bash-4.4# ls config/config2/
external-config2-1.properties  external-config2.properties
bash-4.4# 



subpath的一些限制

k8s 设计的 subpath 其实并不是那么直接
参考:
https://hackmd.io/@maelvls/kubernetes-subpath?utm_source=preview-mode&utm_medium=rec

第1个限制就是 subpath 只能1个文件1个文件地mount, 不支持mount整个folder

参考:
https://kubernetes.io/docs/concepts/configuration/configmap/

第2个限制就是, 用subpath mount的configmap , 即使configmap的值被外部修改, 也不会同步到容器…

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

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

相关文章

TI DSP TMS320F280025 Note9:GPIO输入输出与外部中断功能原理与应用

TMS320F280025 GPIO输入输出与外部中断功能原理与应用 文章目录 TMS320F280025 GPIO输入输出与外部中断功能原理与应用GPIO原理输入输出模式的共同特性1. 复用设置2. 内部上拉设置3. GPIO状态读取 对于输出模式输出电平设置开漏输出设置 对于输入模式极性设置采样类型不同步(异…

CSS3换装达人原理

引言 换装或者是换皮肤是常见的行为&#xff0c;我们可以先看下效果&#xff1a; 选择不同的颜色&#xff0c;就可以秒变人物服装的颜色&#xff0c;原理其实非常简单 实现步骤 主要分为三步&#xff0c;即素材的提供、布局样式、动态控制 图片提供 提供两张图片&#xff…

每日OJ_牛客_红与黑(简单dfs)

目录 牛客_红与黑&#xff08;简单dfs&#xff09; 解析代码 牛客_红与黑&#xff08;简单dfs&#xff09; 红与黑__牛客网 解析代码 循环接收每组用例&#xff0c;对于每组用例进行如下操作&#xff1a; 1. 找到‘’所在的位置&#xff0c;即起始搜索的点 2. 使用DFS搜索地…

20240831-PostgreSQL小课持续更新

PostgreSQL 小课专栏介绍 PostgreSQL 小课目前已累积了近 21 万字。小课最新的大纲&#xff1a; 目前已完成大概 95% 的进度&#xff1a; (venv312) ➜ mypostgres git:(dev) sh scripts/word_statistics_pg_style.shFilename …

【微服务】限流、熔断和降级(持续更新中~)

1、限流 1.1 什么是限流 限流&#xff08;Rate Limiting&#xff09;是一种常用的技术手段&#xff0c;用于控制系统对资源的访问速率&#xff0c;确保系统的稳定性和可靠性。在分布式系统、Web服务、API接口等场景中&#xff0c;限流尤为重要。通过限制请求的频率或数量&…

uniapp u--input实现select下拉列表 input点击事件

背景&#xff1a; 技术框架&#xff1a; uniapp框架(vue2语法)uView组件库。 通过form表单实现数据列表的“查询”功能。注意&#xff1a; 1、<u--form>内部嵌套<u-form-item>&#xff0c;<u-form-item>内部嵌套<u--input>表单组件。 2、H5浏览器端&am…

华为 HCIP-Datacom H12-821 题库

有需要题库的可以看主页置顶 1.MSTP 有不同的端口角色&#xff0c;对此说法不正确的是&#xff1a; A、MSTP 中除边缘端口外&#xff0c;其他端口角色都参与 MSTP 的计算过程 B、MSTP 同一端口在不同的生成树实例中可以担任不同的角色。 C、MSTP 域边缘端口是指位于 MST 域的边…

QT实战项目之音乐播放器

项目效果演示 myMusicShow 项目概述 在本QT音乐播放器实战项目中&#xff0c;开发环境使用的是QT Creator5.14版本。该项目实现了音乐播放器的基本功能&#xff0c;例如开始播放、停止播放、下一首播放、上一首播放、调节音量、调节倍速、设置音乐播放模式等。同时还具备搜索功…

SPR系列单点激光测距传感器|模组之RS485串口调试说明

SPR系列单点激光测距传感器|模组是一款近程红外测距传感器&#xff0c;测距距离可达0-10米&#xff0c;可用于对物体进行非接触式距离测量&#xff0c;其应用场景十分广泛工业自动化&#xff1a;在生产线、传送带等工业自动化场景中&#xff0c;可以使用红外测距传感器进行物体…

Git安装及配置

Git安装 在你开始使用 Git 前,需要将它安装在你的计算机上。 即便已经安装,最好将它升级到最新的版本。 你可以通过软件包或者其它安装程序来安装,或者下载源码编译安装。 下面,我们将会介绍不同操作系统上 Git 的安装方法。 在 Windows 上安装 在 Windows 上安装 Git 的…

LangChain基础知识

这篇文档介绍了LangChain大模型应用开发框架的入门知识和核心内容&#xff0c;包括LangChain是什么、为什么需要它、典型使用场景、基础概念与模块化设计等。同时&#xff0c;还详细阐述了该框架的核心模块如标准化的大模型抽象、大模型应用的最佳实践、赋予应用记忆的能力、框…

JDBC |封装JDBCUtils|PreparedStatement|事务|批处理|数据库连接池| Blob类型数据的读写|Apache—DBUtils简介

一.概述 在Java中&#xff0c;数据库存取技术可分为如下几类&#xff1a; JDBC直接访问数据库JDO技术&#xff08;Java Data Object&#xff09;第三方O/R工具&#xff0c;如Hibernate, Mybatis 等 JDBC是java访问数据库的基石&#xff0c;JDO, Hibernate等只是更好的封装了J…

计算多图的等价无向图的邻接链表表示

计算多图的等价无向图的邻接链表表示 摘要:一、引言二、算法思路三、伪代码实现四、C代码实现五、算法分析六、结论摘要: 在图论中,多图(Multigraph)是一种允许边重复以及存在自循环边(即一个顶点到其自身的边)的图。给定一个多图的邻接链表表示,本文旨在探讨如何构造…

用EA和SysML一步步建模(03)创建包图和包的关系

用EA和SysML一步步建模的操作指南&#xff08;01&#xff09; 用EA和SysML一步步建模&#xff08;02&#xff09;导入ISO-80000 接下来&#xff0c;按照下图添加上其他的包&#xff1a; 步骤 2.2 选中Browser中的“蒸馏器项目”&#xff0c;点击New Package&#xff08;Br…

windows C++ 并行编程-C++ AMP 图形(二)

文中的"显存"还没有找到合适的中文翻译&#xff0c;它的英文名称是texture&#xff0c; 在应用开发者来看,texture是一个名词,在物理上指的是 GPU显存中一段连续的空间。 读取显存对象 可以使用 texture::operator[]、texture::operator() 运算符或 texture::get 方…

物流需求回复势头稳定,目前全国社会物流总额达197.7万亿元

中国物流与采购联合会29日公布今年1-7月份物流运行数据。数据显示&#xff0c;物流需求恢复势头基本稳定&#xff0c;7月份虽受部分地区高温多雨等短期因素扰动&#xff0c;但物流总额增速环比有所提升&#xff0c;呈现温和回升态势。 今年1-7月份&#xff0c;全国社会物流总额…

数据仓库系列17:元数据管理在数据仓库中的作用是什么?

想象一下,你正在管理一个巨大的图书馆,里面存放着数以万计的书籍。但是,这个图书馆没有任何目录、索引或分类系统。你能想象找到特定的一本书会有多困难吗?这就是没有元数据管理的数据仓库的真实写照。 目录 什么是元数据?元数据管理的重要性元数据在数据仓库中的类型1. 技术…

Open3D mesh Taubin滤波

目录 一、概述 1.1原理 1.2实现步骤 1.3应用场景 二、代码实现 2.1关键函数 参数详解 返回值 2.2完整代码 三、实现效果 3.1加入噪声的mesh 3.2Taubin迭代10次 3.3Taubin迭代100次 Open3D点云算法汇总及实战案例汇总的目录地址&#xff1a; Open3D点云算法与点云…

【学习笔记】卫星通信发展趋势

卫星通信系统是融合现代通信技术、航天技术与计算机技术的综合应用&#xff0c;已成为国际与国内通信、国防、移动通信及广播电视领域的关键基础设施。基于其频带宽度大、通信容量高、业务兼容性强、覆盖范围广、性能稳定、地理条件适应性高及成本与距离无关等特性&#xff0c;…

猫咪浮毛不再乱飞 希喂、霍尼韦尔、352宠物空气净化器功能实测

“你真的养猫了吗&#xff1f;为什么一点也看不出来&#xff1f;”养宠以来我经常收到这样的提问&#xff0c;原因是另一位铲屎官身上总会时不时出现猫咪毛发&#xff0c;标记着他的身份。哪有不会掉毛的猫咪呢&#xff0c;何况到了夏天&#xff0c;换毛季的掉毛量更是惊人。其…