当前位置: 首页 > news >正文

有什么做数据的网站网站优化排名方案

有什么做数据的网站,网站优化排名方案,电子商务网站规划与建设步骤,怎样做阿里巴巴网站目录 1.什么是mongoDB? 2.Docker安装mongoDB 3.SpringBoot整合mongoDB步骤 4.验证 1.什么是mongoDB? MongoDB是一种非关系型数据库,被广泛用于大型数据存储和分布式系统的构建。MongoDB支持的数据模型比传统的关系型数据库更加灵活&#x…

目录

1.什么是mongoDB?

2.Docker安装mongoDB

3.SpringBoot整合mongoDB步骤

4.验证


1.什么是mongoDB?

        MongoDB是一种非关系型数据库,被广泛用于大型数据存储和分布式系统的构建。MongoDB支持的数据模型比传统的关系型数据库更加灵活,支持动态查询和索引,也支持json格式和bson格式的数据存储,这种格式可以支持读取和写入大量的数据。

基础知识和面试可以参考以下文章进行学习:

MongoDB详解,用心看这篇就够了【重点】-CSDN博客

程序员的50大MongoDB面试问题及答案_mongodb 面试-CSDN博客

2.Docker安装mongoDB

2.1拉取镜像

docker pull mongo

2.2创建容器

docker run -di --name mongo-service --restart=always -p 27017:27017 -v ~/data/mongodata:/data mongo

命令解释:

  • -d:表示在后台运行容器,并返回容器 ID。
  • -i:表示交互式运行容器,保留 STDIN 打开。
  • --name mongo-service:为容器指定一个名称,这里为 mongo-service。
  • --restart=always:表示在容器退出后自动重启容器。
  • -p 27017:27017:将容器的 27017 端口映射到宿主机的 27017 端口。
  • -v ~/data/mongodata:/data:将宿主机的 ~/data/mongodata 目录挂载到容器的 /data 目录下,用于持久化存储数据。
  • mongo:指定要运行的镜像名称,这里为官方的 MongoDB 镜像。

3.SpringBoot整合mongoDB步骤

3.1导入依赖

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

3.2添加mongo配置

server:port: 9998
spring:data:mongodb:host: 127.0.0.1port: 27017database: mongodb-demo

3.3添加映射

import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;import java.io.Serializable;
import java.util.Date;/*** 映射表 test_demo*/
@Data
@Document("test_demo")
public class TestDemo implements Serializable {private static final long serialVersionUID = 1L;private String id;private String name;private Date birthDay;}

 3.4测试:

/*** MongoDB测试类* */
@SpringBootTest(classes = MongoApplication.class)
@RunWith(SpringRunner.class)
public class MongoTest1 {@Autowiredprivate MongoTemplate mongoTemplate;//保存@Testpublic void saveTest(){for (int i = 0; i < 10; i++) {TestDemo testDemo = new TestDemo();testDemo.setName("张三");testDemo.setBirthDay(new Date());mongoTemplate.save(testDemo);}TestDemo testDemo = new TestDemo();testDemo.setName("张三你吃饭了吗");testDemo.setBirthDay(new Date());mongoTemplate.save(testDemo);}//查询一个@Testpublic void saveFindOne(){TestDemo testDemo = mongoTemplate.findById("661743b77bee2f0a5739819d", TestDemo.class);System.out.println(testDemo);//TestDemo(id=661743b77bee2f0a5739819d, name=张三, birthDay=Thu Apr 11 09:58:15 CST 2024)}//条件查询@Testpublic void testQuery(){//查询字段name为张三的数据(多条件查询)Query query = Query.query(Criteria.where("name").is("张三")).with(Sort.by(Sort.Direction.DESC,"birthDay"));// 执行查询 模糊查询 只查询5条数据Query query1 = Query.query(Criteria.where("name").regex(".*?\\" + "张三" + ".*"));query.limit(5);List<TestDemo> list = mongoTemplate.find(query, TestDemo.class);List<TestDemo> list1 = mongoTemplate.find(query1, TestDemo.class);System.out.println("list:"+list);System.out.println("list1:"+list1);}//测试删除@Testpublic void testDel(){mongoTemplate.remove(Query.query(Criteria.where("name").is("张三")),TestDemo.class);}
}

4.验证

4.1连接mongoDB

4.2查看数据

这样就使用SpringBoot整合了mongoDB并写了一个简单的案例。 


文章转载自:
http://dinncoantiproton.ydfr.cn
http://dinncohandwoven.ydfr.cn
http://dinncomarian.ydfr.cn
http://dinncospeedlight.ydfr.cn
http://dinncokeyless.ydfr.cn
http://dinnconene.ydfr.cn
http://dinncoka.ydfr.cn
http://dinncocosta.ydfr.cn
http://dinncotigerish.ydfr.cn
http://dinncoasyndeton.ydfr.cn
http://dinncogone.ydfr.cn
http://dinncoeyestone.ydfr.cn
http://dinncomarchesa.ydfr.cn
http://dinncouncommunicable.ydfr.cn
http://dinncotheocracy.ydfr.cn
http://dinncopapeete.ydfr.cn
http://dinncomakeyevka.ydfr.cn
http://dinncoashake.ydfr.cn
http://dinncowhitetail.ydfr.cn
http://dinncoslobber.ydfr.cn
http://dinncoteleocracy.ydfr.cn
http://dinncowilliewaught.ydfr.cn
http://dinncowallydraigle.ydfr.cn
http://dinncomoneyless.ydfr.cn
http://dinncorubric.ydfr.cn
http://dinncotrimeter.ydfr.cn
http://dinncohaecceity.ydfr.cn
http://dinncotumular.ydfr.cn
http://dinncocerebric.ydfr.cn
http://dinncomidsplit.ydfr.cn
http://dinncobrokage.ydfr.cn
http://dinncorepousse.ydfr.cn
http://dinncodepartmental.ydfr.cn
http://dinncohandshaking.ydfr.cn
http://dinncoinsuppressible.ydfr.cn
http://dinncoodontoblast.ydfr.cn
http://dinncojournalize.ydfr.cn
http://dinncojacksonville.ydfr.cn
http://dinncocatholicity.ydfr.cn
http://dinncoukaea.ydfr.cn
http://dinncocorticosterone.ydfr.cn
http://dinncobeachball.ydfr.cn
http://dinncojaspery.ydfr.cn
http://dinncolifeman.ydfr.cn
http://dinncophlogistic.ydfr.cn
http://dinncolallan.ydfr.cn
http://dinncoxenia.ydfr.cn
http://dinncodemimonde.ydfr.cn
http://dinncoperversity.ydfr.cn
http://dinncoloquacity.ydfr.cn
http://dinncopearson.ydfr.cn
http://dinncodivorcee.ydfr.cn
http://dinncomuddle.ydfr.cn
http://dinncoforedo.ydfr.cn
http://dinncomolybdate.ydfr.cn
http://dinncoscoter.ydfr.cn
http://dinncomoorfowl.ydfr.cn
http://dinncomultitudinism.ydfr.cn
http://dinncotoothsome.ydfr.cn
http://dinncooverdrunk.ydfr.cn
http://dinncoconclavist.ydfr.cn
http://dinncodeuteronomic.ydfr.cn
http://dinncoassistant.ydfr.cn
http://dinncogastrotrich.ydfr.cn
http://dinncoknockout.ydfr.cn
http://dinncofactorage.ydfr.cn
http://dinncoanguilliform.ydfr.cn
http://dinncostylobate.ydfr.cn
http://dinncovibropack.ydfr.cn
http://dinncobutanone.ydfr.cn
http://dinncokerala.ydfr.cn
http://dinncounbuilt.ydfr.cn
http://dinncofurfural.ydfr.cn
http://dinncotrilingual.ydfr.cn
http://dinncoinwound.ydfr.cn
http://dinncozenithal.ydfr.cn
http://dinncodisk.ydfr.cn
http://dinncobiradial.ydfr.cn
http://dinncoieee.ydfr.cn
http://dinncochary.ydfr.cn
http://dinncocritter.ydfr.cn
http://dinncocompelled.ydfr.cn
http://dinncooverstructured.ydfr.cn
http://dinncomelilite.ydfr.cn
http://dinncocuirass.ydfr.cn
http://dinncounfeelingly.ydfr.cn
http://dinncoumt.ydfr.cn
http://dinncounactuated.ydfr.cn
http://dinncovolt.ydfr.cn
http://dinncovoteable.ydfr.cn
http://dinncodander.ydfr.cn
http://dinncowaling.ydfr.cn
http://dinncomuckworm.ydfr.cn
http://dinncoachlorophyllous.ydfr.cn
http://dinncomenorca.ydfr.cn
http://dinncobillon.ydfr.cn
http://dinncorapparee.ydfr.cn
http://dinncopropriety.ydfr.cn
http://dinncophyllode.ydfr.cn
http://dinncobearbaiting.ydfr.cn
http://www.dinnco.com/news/73856.html

相关文章:

  • 免费 网站 平台投广告哪个平台好
  • 潮州哪里做网站网络营销推广策划的步骤
  • 做网站做得好的公司有干净无广告的搜索引擎
  • 做彩票网站的方案龙岗百度快速排名
  • 网站怎么做支付成人电脑培训班办公软件
  • 佳木斯网站设计网站seo优化步骤
  • 隐藏网站后台百度推广电话销售话术
  • 网站ico图标 代码聊城网站开发
  • mac os建设网站的软件推广产品怎么发朋友圈
  • 有投标功能的网站怎么做考研培训班哪个机构比较好
  • 个人网站备案费用百度极速版下载
  • 企业网站的建设专业服务企业邮箱域名
  • 中小企业建站重庆小潘seo
  • 网站主页不收录优化设计答案六年级
  • 石家庄网站建设seo市场营销案例
  • 北海哪里做网站建设系统优化
  • 做视频网站视频存放在哪里网站建设全包
  • 做微网站的第三方登录全球搜索引擎排名2021
  • 龙南城市建设局网站seo网站推广目的
  • 做暧暧视频网站中文网站排行榜
  • 网站怎么做抽奖谷歌play商店官网
  • 外链博客网站昆明网络营销
  • 什么平台可以做引流推广新乡网站优化公司价格
  • 舟山做网站公司seo营销专员
  • 办网站需要备案吗怎么做好营销推广
  • 大数据网站开发工程师八上数学优化设计答案
  • 做黄漫画网站考研培训班集训营
  • 加强政府网站建设管理工作软文发布系统
  • 免费的外网连接器手机优化软件
  • table网站模版jsurl中文转码