springboot操作nosql的mongodb,或者是如何在mongodb官网创建服务器并进行操作

第一步:在mongodb的官网里面创建云服务器

点进去

这是免费的,由于是一个项目只可以创建一个,这里我已经创建好了

用本地的mongodb服务也是可以的

第二步:点击connect,下载连接mongodb的软件:MongoDBCompass

第三步:创建springboot项目

3.1 、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><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.0.12-SNAPSHOT</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>dev.farhan</groupId><artifactId>movies</artifactId><version>0.0.1-SNAPSHOT</version><name>movies</name><description>a simple APIS relates to movies</description><properties><java.version>17</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-mongodb</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><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></dependency><!-- https://mvnrepository.com/artifact/me.paulschwarz/spring-dotenv --><dependency><groupId>me.paulschwarz</groupId><artifactId>spring-dotenv</artifactId><version>2.5.4</version></dependency></dependencies><build><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></plugins></build><repositories><repository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></repository><repository><id>spring-snapshots</id><name>Spring Snapshots</name><url>https://repo.spring.io/snapshot</url><releases><enabled>false</enabled></releases></repository></repositories><pluginRepositories><pluginRepository><id>spring-milestones</id><name>Spring Milestones</name><url>https://repo.spring.io/milestone</url><snapshots><enabled>false</enabled></snapshots></pluginRepository><pluginRepository><id>spring-snapshots</id><name>Spring Snapshots</name><url>https://repo.spring.io/snapshot</url><releases><enabled>false</enabled></releases></pluginRepository></pluginRepositories></project>

3.2 配置文件:

spring.data.mongodb.database=${env.MONGO_DATABASE}
spring.data.mongodb.uri=mongodb+srv://${env.MONGO_USER}:${env.MONGO_PASSWORD}@${env.MONGO_CLUSTER}

.env文件:

MONGO_DATABASE=这个是你的那个数据库
MONGO_USER=账号
MONGO_PASSWORD=密码
MONGO_CLUSTER=服务器的节点

这些信息都是可以在服务器那边连接的时候看到

创建实体类:

package dev.farhan.movies.pojo;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.DocumentReference;import java.util.List;@Document(collection = "movies")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Movie {@Idprivate ObjectId id;private String imdbId;private String title;private String releaseDate;private String trailerLink;private String poster;private List<String> backdrops;private List<String> genres;@DocumentReferenceprivate List<Review> reviews;public Movie(String imdbId, String title, String releaseDate, String trailerLink, String poster, List<String> backdrops, List<String> genres) {this.imdbId = imdbId;this.title = title;this.releaseDate = releaseDate;this.trailerLink = trailerLink;this.poster = poster;this.backdrops = backdrops;this.genres = genres;}
}

sql:

[{"_id": {"$oid": "652a7733d3f2daf0d09eb498"},"imdbId": "tt3447590","title": "Roald Dahl's Matilda the Musical","releaseDate": "2022-11-25","trailerLink": "https://www.youtube.com/watch?v=lroAhsDr2vI","genres": ["Fantasy","Family","Comedy"],"poster": "https://image.tmdb.org/t/p/w500/ga8R3OiOMMgSvZ4cOj8x7prUNYZ.jpg","backdrops": ["https://image.tmdb.org/t/p/original/nWs0auTqn2UaFGfTKtUE5tlTeBu.jpg","https://image.tmdb.org/t/p/original/bPftMelR4N3jUg2LTlEblFz0gWk.jpg","https://image.tmdb.org/t/p/original/u2MLMkGEjJGQDs17Vmoej1RYFph.jpg","https://image.tmdb.org/t/p/original/jG52tsazn04F1fe8hPZfVv7ICKt.jpg","https://image.tmdb.org/t/p/original/4INEI7t7Vcg0cFvze7UIgwYCeSG.jpg","https://image.tmdb.org/t/p/original/krAu6znzW8c54NdJPneNi4bem1l.jpg","https://image.tmdb.org/t/p/original/6TUMppDMrYA4gzoaDUbbSnZFlxW.jpg","https://image.tmdb.org/t/p/original/hacV1h1SWrPlrerF3xpetvEdqT.jpg","https://image.tmdb.org/t/p/original/7iXsB1r9IK17ZFShqoxcHKQ7dLp.jpg","https://image.tmdb.org/t/p/original/dwiRYDLcFyDOkgkSc1JFtTr6Kdk.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb499"},"imdbId": "tt9114286","title": "Black Panther: Wakanda Forever","releaseDate": "2022-11-11","trailerLink": "https://www.youtube.com/watch?v=_Z3QKkl1WyM","genres": ["Action","Adventure","Science Fiction"],"poster": "https://image.tmdb.org/t/p/w500/cryEN3sWlgB2wTzcUNVtDGI8bkM.jpg","backdrops": ["https://image.tmdb.org/t/p/original/yYrvN5WFeGYjJnRzhY0QXuo4Isw.jpg","https://image.tmdb.org/t/p/original/xDMIl84Qo5Tsu62c9DGWhmPI67A.jpg","https://image.tmdb.org/t/p/original/cs3LpA38BS2XDPfUzdgMB537XOo.jpg","https://image.tmdb.org/t/p/original/6SGMzCsaU094Mt32IHGkIYtIl06.jpg","https://image.tmdb.org/t/p/original/bty0TwJGsxMqYRptgyzn28Cxq5y.jpg","https://image.tmdb.org/t/p/original/h2jp3CSdTPc22mUqps9I8vXDPaN.jpg","https://image.tmdb.org/t/p/original/fSfWloWi5rmqbmC7GhO0HY2TMZW.jpg","https://image.tmdb.org/t/p/original/vZujZnmkYB5nGUC5d5llK9DbGLk.jpg","https://image.tmdb.org/t/p/original/8sMmAmN2x7mBiNKEX2o0aOTozEB.jpg","https://image.tmdb.org/t/p/original/geI3Mk7nehX1kvyIY3K5ajaiNfI.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb492"},"imdbId": "tt3915174","title": "Puss in Boots: The Last Wish","releaseDate": "2022-12-21","trailerLink": "https://www.youtube.com/watch?v=tHb7WlgyaUc","genres": ["Animation","Action","Adventure","Comedy","Family"],"poster": "https://image.tmdb.org/t/p/w500/1NqwE6LP9IEdOZ57NCT51ftHtWT.jpg","backdrops": ["https://image.tmdb.org/t/p/original/r9PkFnRUIthgBp2JZZzD380MWZy.jpg","https://image.tmdb.org/t/p/original/faXT8V80JRhnArTAeYXz0Eutpv9.jpg","https://image.tmdb.org/t/p/original/pdrlEaknhta2wvE2dcD8XDEbAI4.jpg","https://image.tmdb.org/t/p/original/tGwO4xcBjhXC0p5qlkw37TrH6S6.jpg","https://image.tmdb.org/t/p/original/cP8YNG3XUeBmO8Jk7Skzq3vwHy1.jpg","https://image.tmdb.org/t/p/original/qLE8yuieTDN93WNJRmFSAEJChOg.jpg","https://image.tmdb.org/t/p/original/vNuHqmOJRQXY0PBd887DklSDlBP.jpg","https://image.tmdb.org/t/p/original/uUCc62M0I3lpZy0SiydbBmUIpNi.jpg","https://image.tmdb.org/t/p/original/2wPJIFrBhzzAP8oHDOlShMkERH6.jpg","https://image.tmdb.org/t/p/original/fnfirCEDIkxZnQEtEMMSgllm0KZ.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb493"},"imdbId": "tt1630029","title": "Avatar: The Way of Water","releaseDate": "2022-12-16","trailerLink": "https://www.youtube.com/watch?v=d9MyW72ELq0","genres": ["Science Fiction","Action","Adventure"],"poster": "https://image.tmdb.org/t/p/w500/t6HIqrRAclMCA60NsSmeqe9RmNV.jpg","backdrops": ["https://image.tmdb.org/t/p/original/s16H6tpK2utvwDtzZ8Qy4qm5Emw.jpg","https://image.tmdb.org/t/p/original/evaFLqtswezLosllRZtJNMiO1UR.jpg","https://image.tmdb.org/t/p/original/198vrF8k7mfQ4FjDJsBmdQcaiyq.jpg","https://image.tmdb.org/t/p/original/zaapQ1zjKe2BGhhowh5pM251Gpl.jpg","https://image.tmdb.org/t/p/original/tQ91wWQJ2WRNDXwxuO7GCXX5VPC.jpg","https://image.tmdb.org/t/p/original/5gPQKfFJnl8d1edbkOzKONo4mnr.jpg","https://image.tmdb.org/t/p/original/2fS9cpar9rzxixwnRptg4bGmIym.jpg","https://image.tmdb.org/t/p/original/fkGR1ltNbvERk3topo4dP3gWsvR.jpg","https://image.tmdb.org/t/p/original/rb9IHprKNoSKqatP2vr25unUDSu.jpg","https://image.tmdb.org/t/p/original/37ZswIuRQcRBN7kHij5MBjzRMRt.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb49a"},"imdbId": "tt10298840","title": "Strange World","releaseDate": "2022-11-23","trailerLink": "https://www.youtube.com/watch?v=bKh2G73gCCs","genres": ["Family","Adventure","Science Fiction","Animation"],"poster": "https://image.tmdb.org/t/p/w500/kgJ8bX3zDQDM2Idkleis28XSVnu.jpg","backdrops": ["https://image.tmdb.org/t/p/original/5wDBVictj4wUYZ31gR5WzCM9dLD.jpg","https://image.tmdb.org/t/p/original/zNIlXd7CAz0hHAInbs2nsFRc0xQ.jpg","https://image.tmdb.org/t/p/original/1rukJHAP5p6DNHe75Oo1D0m3SnR.jpg","https://image.tmdb.org/t/p/original/aKbe411WyjTZy1OZUVIdNDYVf21.jpg","https://image.tmdb.org/t/p/original/9RKvxz0IryD2ofLYyGpnE7HeWlR.jpg","https://image.tmdb.org/t/p/original/kFURsDklj7QGMMkGJVwDBaJJn05.jpg","https://image.tmdb.org/t/p/original/v6oBDkd7ogXzTQxIU0H5SXq0hOL.jpg","https://image.tmdb.org/t/p/original/fBshLiEJcjdfrU3qQBIINcePSsm.jpg","https://image.tmdb.org/t/p/original/3oie0kID8SNCjkqN6Raweg5dJa.jpg","https://image.tmdb.org/t/p/original/zgFldVKON1Nxp8ui7HVABGKDQKM.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb49b"},"imdbId": "tt8093700","title": "The Woman King","releaseDate": "2022-09-15","trailerLink": "https://www.youtube.com/watch?v=3RDaPV_rJ1Y","genres": ["Action","Drama","History"],"poster": "https://image.tmdb.org/t/p/w500/5O1GLla5vNuegqNxNhKL1OKE1lO.jpg","backdrops": ["https://image.tmdb.org/t/p/original/gkseI3CUfQtMKX41XD4AxDzhQb7.jpg","https://image.tmdb.org/t/p/original/wSILunFEbvw00Ql2aaMHCSZf3cI.jpg","https://image.tmdb.org/t/p/original/xTsERrOCW15OIYl5aPX7Jbj38wu.jpg","https://image.tmdb.org/t/p/original/j06sSrtbqnZdSgG6yEduao95y48.jpg","https://image.tmdb.org/t/p/original/v4YV4ne1nwNni35iz4WmpZRZpCD.jpg","https://image.tmdb.org/t/p/original/6n5ln1vWGD3JyT6Ibt7ZxjSxY3v.jpg","https://image.tmdb.org/t/p/original/gi47WUUYVQWaLE5mJraS87ycdy6.jpg","https://image.tmdb.org/t/p/original/dTQOU5a32K3UPTIXHgipEqN41OM.jpg","https://image.tmdb.org/t/p/original/7zQJYV02yehWrQN6NjKsBorqUUS.jpg","https://image.tmdb.org/t/p/original/rdDL4y7BxGyXFEDJgAG4lz89bG2.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb494"},"imdbId": "tt8760708","title": "M3GAN","releaseDate": "2023-01-06","trailerLink": "https://www.youtube.com/watch?v=BRb4U99OU80","genres": ["Science Fiction","Horror","Comedy"],"poster": "https://image.tmdb.org/t/p/w500/xBl5AGw7HXZcv1nNXPlzGgO4Cfo.jpg","backdrops": ["https://image.tmdb.org/t/p/original/5kAGbi9MFAobQTVfK4kWPnIfnP0.jpg","https://image.tmdb.org/t/p/original/dlxzUj7z1MqEcFiwvvrj0bvBKDY.jpg","https://image.tmdb.org/t/p/original/q2fY4kMXKoGv4CQf310MCxpXlRI.jpg","https://image.tmdb.org/t/p/original/pTxwFdsdDWzpCRYuk1QbggdaOlL.jpg","https://image.tmdb.org/t/p/original/1zuz2RgFoOjulkjjNHHFc3WiHGB.jpg","https://image.tmdb.org/t/p/original/7HqxI1IXMloT9VTSuDC8ikaj810.jpg","https://image.tmdb.org/t/p/original/vpK2rp3J5LiC01HoNM0j9DEHQ1T.jpg","https://image.tmdb.org/t/p/original/cNHXdmr4amP6EPCMa0dqD8rwzDV.jpg","https://image.tmdb.org/t/p/original/txQLFd6rfQrskQhFENkS1jElptt.jpg","https://image.tmdb.org/t/p/original/dC4tj1ONdlZ2TWv4XD2SA1KUnJN.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb495"},"imdbId": "tt11116912","title": "Troll","releaseDate": "2022-12-01","trailerLink": "https://www.youtube.com/watch?v=AiohkY_XQYQ","genres": ["Fantasy","Action","Adventure"],"poster": "https://image.tmdb.org/t/p/w500/9z4jRr43JdtU66P0iy8h18OyLql.jpg","backdrops": ["https://image.tmdb.org/t/p/original/53BC9F2tpZnsGno2cLhzvGprDYS.jpg","https://image.tmdb.org/t/p/original/e9Qb2kmBnMXHCmNMI8NX1JbWhh1.jpg","https://image.tmdb.org/t/p/original/2WjOOOGUu6dp4r8VqR5n48DY7JG.jpg","https://image.tmdb.org/t/p/original/duIsyybgrC4S8kcCIVaxNOttV15.jpg","https://image.tmdb.org/t/p/original/3RS8runn9AfrYDzRVPWuGPmvXQf.jpg","https://image.tmdb.org/t/p/original/8wLRn2VvBlCu6cqYS4ypipnwosr.jpg","https://image.tmdb.org/t/p/original/zDqVVkmfvj47FBUE5lwE4rWnITu.jpg","https://image.tmdb.org/t/p/original/682Ui5DwZDdbIPzKAEOR7cJlMXa.jpg","https://image.tmdb.org/t/p/original/6jdlppcnGi3XuJamfs4Vl7HyxB.jpg","https://image.tmdb.org/t/p/original/uIq83ogs7QBEWi1aqmUrdDIH61m.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb497"},"imdbId": "tt0499549","title": "Avatar","releaseDate": "2009-12-15","trailerLink": "https://www.youtube.com/watch?v=5PSNL1qE6VY","genres": ["Fantasy","Action","Science Fiction","Adventure"],"poster": "https://image.tmdb.org/t/p/w500/jRXYjXNq0Cs2TcJjLkki24MLp7u.jpg","backdrops": ["https://image.tmdb.org/t/p/original/o0s4XsEDfDlvit5pDRKjzXR4pp2.jpg","https://image.tmdb.org/t/p/original/8I37NtDffNV7AZlDa7uDvvqhovU.jpg","https://image.tmdb.org/t/p/original/2YLOjUiczXEgVZFDSIeH3iWB3Ub.jpg","https://image.tmdb.org/t/p/original/Yc9q6QuWrMp9nuDm5R8ExNqbEq.jpg","https://image.tmdb.org/t/p/original/jlQJDD0L5ZojjlS0KYnApdO0n19.jpg","https://image.tmdb.org/t/p/original/sfw4m2tOgQRzhF6VXxaXGfd1vX.jpg","https://image.tmdb.org/t/p/original/7ABsaBkO1jA2psC8Hy4IDhkID4h.jpg","https://image.tmdb.org/t/p/original/xMMrBziwJqrgjerqpNeQvwuwiUp.jpg","https://image.tmdb.org/t/p/original/chauy3iJaZtrMbTr72rgNmOZwo3.jpg","https://image.tmdb.org/t/p/original/mYJkJ7YxJsUNI1nAOOUOpRN2auC.jpg"],"reviewIds": []
},
{"_id": {"$oid": "652a7733d3f2daf0d09eb496"},"imdbId": "tt6443346","title": "Black Adam","releaseDate": "2022-10-19","trailerLink": "https://www.youtube.com/watch?v=JaV7mmc9HGw","genres": ["Fantasy","Action","Science Fiction"],"poster": "https://image.tmdb.org/t/p/w500/pFlaoHTZeyNkG83vxsAJiGzfSsa.jpg","backdrops": ["https://image.tmdb.org/t/p/original/bQXAqRx2Fgc46uCVWgoPz5L5Dtr.jpg","https://image.tmdb.org/t/p/original/9hNtTwY8P5v2MKnUeb7iuREI7Yb.jpg","https://image.tmdb.org/t/p/original/zplntIhzXyBiXFYWReETxh0uyFF.jpg","https://image.tmdb.org/t/p/original/yxkhM18dYwsRRffLnd9lz2d4i0v.jpg","https://image.tmdb.org/t/p/original/bgaBKREAfUtZgvd6zoV6RQRcIUt.jpg","https://image.tmdb.org/t/p/original/uqYxoj4hqwocwfBs2xxGyQT88Yk.jpg","https://image.tmdb.org/t/p/original/qBx97wytqlyPqXATHqRgIVFxJRU.jpg","https://image.tmdb.org/t/p/original/d6MhreFdMHONqX3iZlJGCF8UkIt.jpg","https://image.tmdb.org/t/p/original/9inNotReApz0n50WvWbrt0n1cbL.jpg","https://image.tmdb.org/t/p/original/pSOuqtJmdh7aI1yiK7M8e0PmbPC.jpg"],"reviewIds": []
}]

复制粘贴到一个json文件里面,然后导入:

创建MovieRepository类:

package dev.farhan.movies.repository;import dev.farhan.movies.pojo.Movie;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;import java.util.Optional;@Repository
public interface MovieRepository extends MongoRepository<Movie, ObjectId> {Optional<Movie> findMovieByImdbId(String imdbId);
}

创建MovieService类:

package dev.farhan.movies.service;import dev.farhan.movies.repository.MovieRepository;
import dev.farhan.movies.pojo.Movie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;
import java.util.Optional;@Service
public class MovieService {@Autowiredprivate MovieRepository repository;public List<Movie> findAllMovies() {return repository.findAll();}public Optional<Movie> findMovieByImdbId(String imdbId) {return repository.findMovieByImdbId(imdbId);}
}

创建controller类,进行测试:

package dev.farhan.movies.controller;import dev.farhan.movies.pojo.Movie;
import dev.farhan.movies.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;import java.util.List;
import java.util.Optional;@RestController
@RequestMapping("/api/v1/movies")
public class MovieController {@Autowiredprivate MovieService service;@GetMappingpublic ResponseEntity<List<Movie>> getMovies() {return new ResponseEntity<List<Movie>>(service.findAllMovies(), HttpStatus.OK);}@GetMapping("/{imdbId}")public ResponseEntity<Optional<Movie>> getSingleMovie(@PathVariable String imdbId){return new ResponseEntity<Optional<Movie>>(service.findMovieByImdbId(imdbId), HttpStatus.OK);}
}

启动,并访问:localhost:8080/api/v1/movies

结果:成功

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

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

相关文章

【VUE】ArcoDesign之自定义主题样式和命名空间

前言 Arco Design是什么&#xff1f; Arco Design 是由字节跳动推出的企业级产品的完整设计和开发解决方案前端组件库 官网地址&#xff1a;https://arco.design/同时也提供了一套开箱即用的中后台前端解决方案&#xff1a;Arco Design Pro(https://pro.arco.design/) Arco De…

蓝桥杯 Java 括号序列

本算法需要把问题分解成三步&#xff1a; 第一步&#xff1a;算出 ((() 填充 ( 的方案 第二步&#xff1a;算出 ((() 填充 ) 的方案 第三步&#xff1a;把两个方案相乘 第二步可以把原方案当成将 ((() 逆转成 ())) 再填充 ( &#xff0c;这样就可以重复第一步用的算法 第一步…

Tp框架如何使用事务和锁,还有查询缓存

1.事务 在ThinkPHP框架中&#xff0c;可以使用think\db\Transaction类来实现事务。 use think\Db; use think\db\Transaction;// 开始事务 Db::startTrans();try {// 执行数据库操作Db::table(user)->where(id, 1)->update([name > John]);// 提交事务Db::commit(); }…

JVM基础:字节码文件详解①

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 一、Java虚拟机的组成二、字节码文件的组成2.1 为什么要了解字节码文件&#xff1f;2.2 如何“窥探”字节码文件的奥秘&#xff1f;2.2.1 使用工具打开字节码文件2.…

[论文笔记]GTE

引言 今天带来今年的一篇文本嵌入论文GTE, 中文题目是 多阶段对比学习的通用文本嵌入。 作者提出了GTE,一个使用对阶段对比学习的通用文本嵌入。使用对比学习在多个来源的混合数据集上训练了一个统一的文本嵌入模型,通过在无监督预训练阶段和有监督微调阶段显著增加训练数…

MySQL安装多个实例——批处理脚本一键配置MySQL服务

1.下载mysql的免安装压缩包 官网&#xff1a;https://downloads.mysql.com/archives/community/ 2.解压并新增批处理脚本 echo off chcp 65001 setlocal enabledelayedexpansionecho MySQL版本为8.0.34REM 使用set /p命令获取用户输入的端口号 set /p "port请输入端口号…

LabVIEW开发基于图像处理的车牌检测系统

LabVIEW开发基于图像处理的车牌检测系统 自动车牌识别的一般步骤是图像采集、去除噪声的预处理、车牌定位、字符分割和字符识别。结果主要取决于所采集图像的质量。在不同照明条件下获得的图像具有不同的结果。在要使用的预处理技术中&#xff0c;必须将彩色图像转换为灰度&am…

postgresql14管理(五)-tablespace

基本概念 表空间tablespace在postgresql中&#xff0c;表示数据库对象&#xff08;比如表或索引&#xff09;的存放目录。当表被访问时&#xff0c;系统通过表空间定位到对应数据文件所在的位置。 优势&#xff1a; 1、如果数据库集群所在的初始磁盘分区或磁盘卷的空间不足&a…

企业如何选择设备管理系统?

1、需求为王&#xff0c;列出你的需求清单 每个企业的设备都不尽相同&#xff0c;自然对设备管理系统的需求也不一样。因此&#xff0c;需要充分明确自己的需求和目标&#xff0c;清晰地列出需求清单&#xff0c;然后再逐一对照供应商的产品功能&#xff0c;看是否满足自身各业…

蓝桥杯双周赛算法心得——通关(哈希+小根堆)

大家好&#xff0c;我是晴天学长&#xff0c;这是很重要的贪心思维题&#xff0c;哈希的存法和小根堆的表示很重要。 1) .通关 2) .算法思路 通关 用hash&#xff08;int[]&#xff09;存点的子节点并按输入顺序存关卡的号码&#xff08;输入顺序就是&#xff09; 列如&#…

使用 Pyro 和 PyTorch 的贝叶斯神经网络

一、说明 构建图像分类器已成为新的“hello world”。还记得当你第一次接触 Python 时&#xff0c;你的打印“hello world”感觉很神奇吗&#xff1f;几个月前&#xff0c;当我按照PyTorch 官方教程并为自己构建了一个运行良好的简单分类器时&#xff0c;我也有同样的感觉。 我…

JSON parse error: Cannot deserialize instance of `xxx` out of START_ARRAY token

报错原因 前端传参类型是数组&#xff0c;后端接收参数类型是字符串。 解决办法 前端传参类型改为字符串即可。 如下图 【修改前】 【修改后】

计算机网络-应用层(2)

一、DHCP 当需要跨越多个网段提供DHCP 服务时必须使用DHCP 中继代理&#xff0c; 就是在DHCP 客户和服务器之间转发DHCP 消息的主机或路由器。 DHCP 服务端使用UDP 的67号端口来监听和接收客户请求消息&#xff0c; 保留UDP 的68号端口用于接收来自DHCP 服务器的消息回复。 在…

HTTP 之 options预请求 nginx 解决跨域 postman调试跨域问题

一、HTTP一共有八种常见请求方法 get&#xff1a;参数在url上&#xff0c;浏览器长度有限制&#xff0c;不安全post&#xff1a;参数不可见&#xff0c;长度不受限制put&#xff1a;上传最新内容到指定位置delete&#xff1a;删除请求的url所表示的资源head&#xff1a;不返回…

代码随想录算法训练营第三十五天丨 贪心算法part06

738.单调递增的数字 思路 暴力解法 题意很简单&#xff0c;那么首先想的就是暴力解法了【超时】。 贪心算法 题目要求小于等于N的最大单调递增的整数&#xff0c;那么拿一个两位的数字来举例。 例如&#xff1a;98&#xff0c;一旦出现strNum[i - 1] > strNum[i]的情况…

高精度数字电容传感芯片-MDC04

高精度数字电容传感芯片-MDC04 简介引脚说明PCBA板寄存器说明代码实现单总线通讯时序代码单总线通讯时序代码头文件MDC04驱动代码MDC04驱动代码头文件用户APP调用函数main主程序 简介 MDC04以低成本等优势&#xff0c;可用于智能小家电液位、水箱液位、油液液位、水浸传感、食…

干式电抗器的尺寸和重量对系统有什么影响?

干式电抗器是一种用于电力系统中的无功补偿设备&#xff0c;其尺寸和重量对系统有以下几方面的影响&#xff0c;干式电抗器的尺寸和重量会影响设备的安装和布置&#xff0c;较大尺寸和重量的电抗器需要更大的安装空间&#xff0c;并且可能需要额外的支撑结构。在设计系统时需要…

代码随想录打卡第五十三天|309.最佳买卖股票时机含冷冻期 ● 714.买卖股票的最佳时机含手续费

309.最佳买卖股票时机含冷冻期 题目&#xff1a; 给定一个整数数组prices&#xff0c;其中第 prices[i] 表示第 i 天的股票价格 。​ 设计一个算法计算出最大利润。在满足以下约束条件下&#xff0c;你可以尽可能地完成更多的交易&#xff08;多次买卖一支股票&#xff09;: 卖…

hdlbits系列verilog解答(32位加法器)-25

文章目录 一、问题描述二、verilog源码三、仿真结果 一、问题描述 您将获得一个执行 16 位加法的模块 add16 。实例化其中两个以创建一个 32 位加法器。一个 add16 模块在接收到第一个加法器的进位结果后&#xff0c;计算加法结果的低 16 位&#xff0c;而第二个 add16 模块计…

windows + ubuntu + vscode开发环境配置安装

一、卸载WSL/WSL2 如果安装了windows子系统的朋友&#xff0c;可以选择继续使用。或者提前卸载WSL&#xff0c;再选择安装虚拟机。虚拟机占用内存较大&#xff0c;WSL可能对于开发的一些需求还有欠缺。根据自己的实际情况进行选择。 WIN10/11安装WSL(请参考官方资料&#xff0c…