Cassandra 5.0 Spring Boot 3.3 CRUD

概览

  • 因AI要使用到向量存储,JanusGraph也使用到Cassandra

卸载先前版本

docker stop cassandra && docker remove cassandra && rm -rf cassandra/

运行Cassandra容器

docker run \--name cassandra \--hostname cassandra \-p 9042:9042 \--privileged=true \--net network-common \-v /elf/cassandra:/var/lib/cassandra \-itd cassandra:5.0.0

连接到Cassanra

# docker logs --tail 100 cassandra# 等完全启动后
# docker exec -it cassandra /bin/bash# 查询集群状态,用于应用程序连接等,详情参考Troubleshooting章节
# /opt/cassandra/bin/nodetool status# show version
[cqlsh 6.2.0 | Cassandra 5.0.0 | CQL spec 3.4.7 | Native protocol v5]# cqlsh 127.0.0.1 9042 -u cassandra -p cassandra# describe keyspaces;system       system_distributed  system_traces  system_virtual_schema
system_auth  system_schema       system_views
# /opt/cassandra/bin/nodetool statusDatacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address     Load       Tokens  Owns (effective)  Host ID                               Rack
UN  172.18.0.2  136.3 KiB  16      100.0%            63c1c77a-fa0b-4630-9fd0-9568133bd1df  rack1

Dependency

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-log4j2</artifactId>
</dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>

Product

import java.util.UUID;
import org.springframework.data.cassandra.core.mapping.Column;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;@Table
public class Product {@PrimaryKey@Column(value = "product_id")private UUID productId;@Column(value = "product_name")private String productName;@Column(value = "product_memo")private String productMemo;@Column(value = "product_state")private boolean productState;public Product() {} public Product(UUID productId, String productName,String productMemo, boolean productState) {super();this.productId = productId;this.productName = productName;this.productMemo = productMemo;this.productState = productState;}@Overridepublic String toString() {return "Product [productId=" + productId+ ", productName=" + productName + ", productMemo=" + productMemo + ", productState=" + productState + "]";}public UUID getProductId() {return productId;}public void setProductId(UUID productId) {this.productId = productId;}public String getProductName() {return productName;}public void setProductName(String productName) {this.productName = productName;}public String getProductMemo() {return productMemo;}public void setProductMemo(String productMemo) {this.productMemo = productMemo;}public boolean isProductState() {return productState;}public void setProductState(boolean productState) {this.productState = productState;}}

ProductRepository

import java.util.List;
import java.util.UUID;
import io.os.cassandra.model.Product;
import org.springframework.data.cassandra.repository.AllowFiltering;
import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;@Repository
public interface ProductRepository extends CassandraRepository<Product,UUID> {//@AllowFiltering:允许方法对服务器端筛选,等效于//select * from product where product_state = [true/false];@AllowFilteringList<Product> findByProductState(boolean productState);List<Product> findByProductMemo(String productName);
}

ProductController

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.os.cassandra.model.Product;
import io.os.cassandra.repository.ProductRepository;@RestController
@RequestMapping("/api/product")
public class ProductController {@Autowiredprivate ProductRepository productRepository;@GetMapping("/getAllProductProduct")public ResponseEntity<List<Product>> getAllProductProduct(@RequestParam(required = false,value = "productMemo") String productMemo) {try {List<Product> productList = new ArrayList<Product>();if (productMemo == null) {productRepository.findAll().forEach(productList::add);} else {productRepository.findByProductMemo(productMemo).forEach(productList::add);}if (productList.isEmpty()) {return new ResponseEntity<>(HttpStatus.NO_CONTENT);} else {return new ResponseEntity<>(productList, HttpStatus.OK);}} catch (Exception e) {return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);}}@GetMapping("/getProductById/{id}")public ResponseEntity<Product> getProductById(@PathVariable("id") String id) {var product = productRepository.findById(UUID.fromString(id));if (product.isPresent()) {return new ResponseEntity<>(product.get(), HttpStatus.OK);} else {return new ResponseEntity<>(HttpStatus.NOT_FOUND);}}@PostMapping("/createProduct")public ResponseEntity<Product> createProduct(@RequestBody Product product) {var requestProduct = new Product(UUID.randomUUID(),product.getProductName(),product.getProductMemo(),product.isProductState());try {Product p = productRepository.save(requestProduct);return new ResponseEntity<>(p,HttpStatus.CREATED);} catch (Exception e) {return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);}}@PutMapping("/updateProduct/{id}")public ResponseEntity<Product> updateProduct(@PathVariable("id") String id,@RequestBody Product product) {var updateProduct = productRepository.findById(UUID.fromString(id));if (updateProduct.isPresent()) {var p = updateProduct.get();p.setProductName(product.getProductName());p.setProductMemo(product.getProductMemo());p.setProductState(product.isProductState());return new ResponseEntity<>(productRepository.save(p), HttpStatus.OK);} else {return new ResponseEntity<>(HttpStatus.NOT_FOUND);}}@DeleteMapping("/deleteProductById/{id}")public ResponseEntity<HttpStatus> deleteProductById(@PathVariable("id") String id) {try {productRepository.deleteById(UUID.fromString(id));return new ResponseEntity<>(HttpStatus.NO_CONTENT);} catch (Exception e) {return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);}}@DeleteMapping("/deleteAllProduct")public ResponseEntity<HttpStatus> deleteAllProduct() {try {productRepository.deleteAll();return new ResponseEntity<>(HttpStatus.NO_CONTENT);} catch (Exception e) {return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);}}@GetMapping("/getProductByState")public ResponseEntity<List<Product>> findByProductState() {try {var productList = productRepository.findByProductState(true);if (productList.isEmpty()) {return new ResponseEntity<>(HttpStatus.NO_CONTENT);} else {return new ResponseEntity<>(productList, HttpStatus.OK);}} catch (Exception e) {return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);}}}

application.yaml

  • application.yaml和CassandraConfig.java,二选一
server:port: 8080servlet:context-path: /spring: data:cassandra:repositories:type: imperativecassandra:keyspace-name: elfport: 9042contact-points:- 192.168.0.123:9042schema-action: create-if-not-existspassword: cassandrausername: cassandra# /opt/cassandra/bin/nodetool status命令查询local-datacenter: datacenter1
import java.net.InetSocketAddress;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import com.datastax.oss.driver.api.core.CqlSession;@Configuration
@EnableCassandraRepositories
public class CassandraConfig {@BeanCqlSession session() {return CqlSession.builder().withKeyspace("elf").withAuthCredentials("cassandra", "cassandra").withLocalDatacenter("datacenter1").addContactPoint(InetSocketAddress.createUnresolved("192.168.0.123",9042)).build();}}

CassandraEntry

import java.lang.invoke.MethodHandles;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;@SpringBootApplication
public class CassandraEntry {public static void main(String[] sa) {var cls = MethodHandles.lookup().lookupClass();SpringApplication.run(cls,sa);}}

Environment

# cassandra为Cassandra容器名
docker start cassandra# docker exec -it cassandra /bin/bash# 查询集群状态,用于应用程序连接等,详情参考Troubleshooting章节
# /opt/cassandra/bin/nodetool status# cqlsh 127.0.0.1 9042 -u cassandra -p cassandra# describe keyspaces;

Product.cql

create keyspace if not exists elf with replication={'class':'SimpleStrategy','replication_factor':1};use elf;create table if not exists elf.product(product_id uuid primary key,product_name varchar,product_memo text,product_state boolean
);select * from elf.product;
truncate table elf.product;# 不要换行,不要随意添加空格,否则cql语法可能无法通过;
# UUID:Java UUID.randomUUID()形式,Cassandra uuid()形式;insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'JanusGraph','Graph,Open Source',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Cassandra','Wide Column,Vector,Multi Model',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Presto','Relational,Open Source,Big Data',false);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Trino','Relational,Document,Spatial,TS,KV',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Weaviate','Vector,AI,Real Time',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Milvus','Vector,Similarity Search,ML',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'Qdrant','Vector,NN,Semantic Matching',true);
insert into elf.product(product_id,product_name,product_memo,product_state)values(uuid(),'ElasticSearch','Search,Document,Spatial,Vector',true);
+--------------------------------------+-----------------------------------+---------------+--------------+
| product_id                           | product_memo                      | product_name  | product_state|
|--------------------------------------+-----------------------------------+---------------+--------------|
| 29af0738-4a17-4571-90cd-700ab8995db7 |       Vector,Similarity Search,ML |        Milvus |          True|
| 3a3415aa-8dfa-42fa-9723-0142960b687a |   Relational,Open Source,Big Data |        Presto |         False|
| 741e5240-8a7b-40fa-b07c-e88b3638bf36 |                 Graph,Open Source |    JanusGraph |          True|
| 63608ee0-eaf1-41cf-970e-04238a556103 |               Vector,AI,Real Time |      Weaviate |          True|
| 6d580a60-daba-46cc-b3d9-6061aa48f0ff |    Search,Document,Spatial,Vector | ElasticSearch |          True|
| d4760f62-9b76-4c40-8a56-8c1e7214dfdd |    Wide Column,Vector,Multi Model |     Cassandra |          True|
| ddfe8f96-c49f-4ad0-899a-9b3b484419d8 |       Vector,NN,Semantic Matching |        Qdrant |          True|
| cb99a803-2443-48ec-accb-5262ef9bc429 | Relational,Document,Spatial,TS,KV |         Trino |          True|
+--------------------------------------+-----------------------------------+---------------+--------------+

Visualization Tool

  • 安装DbVisualizer V24.1.4;

  • Tool ☞ Driver Manager ☞ 搜索Cassandra
    ☞ 右键选择Create User Driver from Template
    在这里插入图片描述

  • Name:Custom Cassandra

  • Url:jdbc:cassandra://192.168.0.123:9042

  • Driver Class:com.simba.cassandra.jdbc42.Driver

  • 点击右侧地球仪:Download/Update driver for remote artifact,
    下载完成后关闭窗口;

  • 点击左上角加号 ☞ Create Database Connection:

在这里插入图片描述

  • SQL Commander ☞ New SQL Commander ☞ select * from elf.product;

在这里插入图片描述

Create Product

  • http://localhost:8080/api/product/createProduct

  • 请求方法:POST,请求对象和响应对象分别为:

{"productName":"Cassandra","productMemo":"Wide Column,Vector,Multi Model","productState":true
}{"productId": "24672630-4ca4-424b-8fc5-c20f1400074b","productName": "Cassandra","productMemo": "Wide Column,Vector,Multi Model","productState": true
}

Update Product

  • http://localhost:8080/api/product/updateProduct/productId
    http://localhost:8080/api/product/updateProduct/24672630-4ca4-424b-8fc5-c20f1400074b

  • 请求方法:PUT,请求对象和响应对象分别为:

{"productName":"Cassandra-Update","productMemo":"Wide Column,Vector,Multi Model","productState":true
}{"productId": "24672630-4ca4-424b-8fc5-c20f1400074b","productName": "Cassandra-Update","productMemo": "Wide Column,Vector,Multi Model","productState": true
}

Retrieve By Id

  • 请求方法:GET;

  • http://localhost:8080/api/product/getProductById/productId
    http://localhost:8080/api/product/getProductById/29af0738-4a17-4571-90cd-700ab8995db7

{"productId": "29af0738-4a17-4571-90cd-700ab8995db7","productName": "Milvus","productMemo": "Vector,Similarity Search,ML","productState": true
}

Retrieve All Product

  • 请求方法:GET;

  • http://localhost:8080/api/product/getAllProductProduct

[{"productId": "29af0738-4a17-4571-90cd-700ab8995db7","productName": "Milvus","productMemo": "Vector,Similarity Search,ML","productState": true},{"productId": "3a3415aa-8dfa-42fa-9723-0142960b687a","productName": "Presto","productMemo": "Relational,Open Source,Big Data","productState": false},{"productId": "741e5240-8a7b-40fa-b07c-e88b3638bf36","productName": "JanusGraph","productMemo": "Graph,Open Source","productState": true},{"productId": "63608ee0-eaf1-41cf-970e-04238a556103","productName": "Weaviate","productMemo": "Vector,AI,Real Time","productState": true},{"productId": "6d580a60-daba-46cc-b3d9-6061aa48f0ff","productName": "ElasticSearch","productMemo": "Search,Document,Spatial,Vector","productState": true},{"productId": "d4760f62-9b76-4c40-8a56-8c1e7214dfdd","productName": "Cassandra","productMemo": "Wide Column,Vector,Multi Model","productState": true},{"productId": "ddfe8f96-c49f-4ad0-899a-9b3b484419d8","productName": "Qdrant","productMemo": "Vector,NN,Semantic Matching","productState": true},{"productId": "cb99a803-2443-48ec-accb-5262ef9bc429","productName": "Trino","productMemo": "Relational,Document,Spatial,TS,KV","productState": true}
]
  • http://localhost:8080/api/product/getAllProductProduct?productMemo=vector

  • 关于自定义索引,后续章节说明,此处不再赘述;

select * from elf.product where product_memo like '%vector%';
----[source,sql]
----
InvalidRequest: Error from server: code=2200 [Invalid query] msg="like restriction only support on properly indexed columnproduct_memo LIKE '%vector%' is not valid."

Delete Product

  • 请求方法:DELETE;

  • http://localhost:8080/api/deleteProductById/productId
    http://localhost:8080/api/deleteProductById/6d580a60-daba-46cc-b3d9-6061aa48f0ff

Delete All Product

  • 请求方法:DELETE;

  • http://localhost:8080/api/product/deleteAllProduct

Retrieve By State

  • 请求方法:GET;

  • http://localhost:8080/api/product/getProductByState

[{"productId": "29af0738-4a17-4571-90cd-700ab8995db7","productName": "Milvus","productMemo": "Vector,Similarity Search,ML","productState": true},{"productId": "741e5240-8a7b-40fa-b07c-e88b3638bf36","productName": "JanusGraph","productMemo": "Graph,Open Source","productState": true},{"productId": "63608ee0-eaf1-41cf-970e-04238a556103","productName": "Weaviate","productMemo": "Vector,AI,Real Time","productState": true},{"productId": "d4760f62-9b76-4c40-8a56-8c1e7214dfdd","productName": "Cassandra","productMemo": "Wide Column,Vector,Multi Model","productState": true},{"productId": "ddfe8f96-c49f-4ad0-899a-9b3b484419d8","productName": "Qdrant","productMemo": "Vector,NN,Semantic Matching","productState": true},{"productId": "cb99a803-2443-48ec-accb-5262ef9bc429","productName": "Trino","productMemo": "Relational,Document,Spatial,TS,KV","productState": true}
]

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

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

相关文章

【HarmonyOS】深入理解@Observed装饰器和@ObjectLink装饰器:嵌套类对象属性变化

【HarmonyOS】深入理解Observed装饰器和ObjectLink装饰器&#xff1a;嵌套类对象属性变化 前言 之前就Observed和ObjectLink写过一篇讲解博客【HarmonyOS】 多层嵌套对象通过ObjectLink和Observed实现渲染更新处理&#xff01; 其中就Observe监听类的使用&#xff0c;Object…

ZXing.Net:一个开源条码生成和识别器,支持二维码、条形码等

推荐一个跨平台的非常流行的条码库&#xff0c;方便我们在.Net项目集成条码扫描和生成功能。 01 项目简介 ZXing.Net是ZXing的.Net版本的开源库。支持跨多个平台工作&#xff0c;包括 Windows、Linux 和 macOS&#xff0c;以及在 .NET Core 和 .NET Framework 上运行。 解码…

硬件看门狗导致MCU启动时间慢

最近&#xff0c;在项目交付过程中&#xff0c;我们遇到了一个有趣的问题&#xff0c;与大家分享一下。 客户的需求是&#xff1a;在KL15电压上电后&#xff0c;MCU需要在200ms内发送出第一包CAN报文数据。然而&#xff0c;实际测试结果显示&#xff0c;软件需要360ms才能发送…

【通俗易懂介绍OAuth2.0协议以及4种授权模式】

文章目录 一.OAuth2.0协议介绍二.设计来源于生活三.关于令牌与密码的区别四.应用场景五.接下来分别简单介绍下四种授权模式吧1.客户端模式1.1 介绍1.2 适用场景1.3 时序图 2.密码模式2.1 介绍2.2 适用场景2.3时序图 3.授权码模式3.1 介绍3.2 适用场景3.3 时序图 4.简化模式4.1 …

MES系统如何提升制造企业的运营效率和灵活性

参考拓展&#xff1a;苏州稳联-西门子MES系统-赋能智能制造的核心引擎 制造执行系统(MES)在提升制造企业运营效率和灵活性方面发挥着关键作用。 一、MES系统的基本概念和功能 MES系统是连接企业管理层与生产现场的重要桥梁。它主要负责生产调度、资源管理、质量控制等多个方…

安全热点问题

安全热点问题 1.DDOS2.补丁管理3.堡垒机管理4.加密机管理 1.DDOS 分布式拒绝服务攻击&#xff0c;是指黑客通过控制由多个肉鸡或服务器组成的僵尸网络&#xff0c;向目标发送大量看似合法的请求&#xff0c;从而占用大量网络资源使网络瘫痪&#xff0c;阻止用户对网络资源的正…

TMStarget学习——T1 Segmentation数据处理及解bug

最新学习季公俊老师的神器 TMStarget 的第一个模块基于结构像的靶区计算T1 segmentation。下面上步骤&#xff1a; (1)在github 上下载 TMStarget https://github.com/jigongjun/Neuroimaging-and-Neuromodulation (2)按照要求下载依赖工具软件AFQ、vistasoft、SPM12 &#…

OpenAI o1团队突破性论文:『过程推理』中数学推理能力大幅提升,从正确中学习的新方法

原创 超 近年来&#xff0c;大型语言模型(LLMs)在复杂的多步推理任务中取得了令人瞩目的进展。这些模型能够生成逐步的思维链&#xff0c;解决从小学数学到高等微积分的各种问题。然而&#xff0c;即使是最先进的模型也常常陷入逻辑陷阱&#xff0c;产生看似合理但实际错误的推…

1.3 计算机网络的分类

欢迎大家订阅【计算机网络】学习专栏&#xff0c;开启你的计算机网络学习之旅&#xff01; 文章目录 前言一、按分布范围分类二、按传输技术分类三、按拓扑结构分类四、按使用者分类五、按传输介质分类 前言 计算机网络根据不同的标准可以被分为多种类型&#xff0c;本章从分布…

QT----基于QML的计时器

赶上了实习的末班车,现在在做QML开发,第一天的学习成果,一个计时器.逻辑挺简单的,纯QML实现,代码在仓库QT-Timer 学习使用c的listmodel 学习使用了如何用c的listmodel来存储数据. 新建一个TImeListModel类继承自QAbstractListModel class TimeListModel : public QAbstrac…

STM32CUBEIDE FreeRTOS操作教程(五):mutex互斥信号量

STM32CUBEIDE FreeRTOS操作教程&#xff08;五&#xff09;&#xff1a;mutex互斥信号量 STM32CUBE开发环境集成了STM32 HAL库进行FreeRTOS配置和开发的组件&#xff0c;不需要用户自己进行FreeRTOS的移植。这里介绍最简化的用户操作类应用教程。以STM32F401RCT6开发板为例&am…

蓝牙技术|详谈蓝牙信道探测技术,可实现厘米级精准定位

2024年9月5日&#xff0c;蓝牙技术联盟发布蓝牙6.0核心规范。相比此前各版本&#xff0c;蓝牙核心规范6.0版的主要创新和新功能包括&#xff1a;支持蓝牙信道探测、同步适配层增强、LL扩展功能和 帧空间更新。 蓝牙信道探测 市场上已经有不少高精度定位技术了&#xff0c;像 …

ToF传感器更新

我们最近改进了 ToF 解码管道&#xff08;固件&#xff09;和 ToF 工厂校准&#xff0c;该校准已应用于我们最新的带有 ToF 相机的OAK-D-SR-PoE 1. 点云 这是直接来自摄像机的原始点云&#xff08;没有应用任何后处理过滤器&#xff09;。 2. ToF 精度 &#xff08;ToF 深度误差…

界面控件Telerik UI for WinForms 2024 Q3概览 - 支持合并单元格等

Telerik UI for WinForms拥有适用Windows Forms的110多个令人惊叹的UI控件。所有的UI for WinForms控件都具有完整的主题支持&#xff0c;可以轻松地帮助开发人员在桌面和平板电脑应用程序提供一致美观的下一代用户体验。 本文将介绍界面组件Telerik UI for WinForms在今年第一…

3d可视化图片:通过原图和深度图实现

1、depthy 在线体验demo: https://depthy.stamina.pl/#/ 也可以docker安装上面服务: docker run --rm -t -i -p 9000:9000 ndahlquist/depthy http://localhost:90001)首先传原图 2)再传对应深度图 3)效果 </ifra

Linux ubuntu debian系统安装UFW防火墙图形化工具GUFW

GUFW是UFW的图形化前端&#xff0c;可以通过以下命令安装&#xff1a; sudo apt install gufw安装成功后&#xff0c;可以通过应用程序菜单启动GUFW&#xff0c;在图形界面中&#xff0c;可以方便地添加、修改和删除规则&#xff0c;查看状态和日志。

分布式系统的概念与设计模式

概念 定义&#xff1a;分布式系统是指将数据和计算任务分散到多个独立的计算机上&#xff0c;这些计算机通过网络进行通信和协作&#xff0c;共同对外提供服务。分布式系统不仅提高了系统的可靠性和可扩展性&#xff0c;还增强了系统的并发处理能力和数据管理能力。 特点&…

【操作系统强化】王道强化一轮笔记

第一章 计算机系统概述 考点1 操作系统的概念、特征和功能 1. 2. 考点2 内核态与用户态 1. 2.用户态和内核态之间的切换本质上就是应用程序和操作系统对CPU控制器的切换 考点3 中断和异常 1. 2. 考点4 系统调用 1. 2. 3.C 考点5 操作系统引导 1. 2. ①磁盘的物理格式化&…

React-Native 中使用 react-native-image-crop-picker 在华为手机上不能正常使用拍照功能

背景: React-Native 0.66 中使用 react-native-image-crop-picker 在安卓 华为手机上不能正常使用拍照功能, 其他品牌正常 代码如下: import ImagePicker from react-native-image-crop-picker;ImagePicker.openCamera(photoOptions).then(image > {callback(image);}) …

库仑定律-库仑力-两个电荷之间静电力的计算公式

图中&#xff1a; q1&#xff0c;q2 为两个电荷r 为电荷间的距离 r ^ 1 , 2 \widehat{r}_{1,2} r 1,2​ 为从 q1 指向 q2 的单位向量 F ⃗ 1 , 2 \vec{F}_{1,2} F 1,2​ 为 q1 施加到 q2 上的静电力 公式&#xff1a; F ⃗ 1 , 2 q 1 q 2 K r 2 r ^ 1 , 2 \vec{F}_{1,2} \f…