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

创建网站要多少钱平台推广是什么

创建网站要多少钱,平台推广是什么,wordpress和主题,湛江网站建设方案服务在SpringBoot项目中集成MongoDB后的一些基本操作。 文章目录 前言一、pandas是什么#xff1f;二、使用步骤 1.引入库2.读入数据总结 前言 本文介绍的内容是Springboot如何集成MongoDB#xff0c;以及对MongoDB进行基本的增加、查询数据的操作。 提示#xff1a;以下是本篇… 在SpringBoot项目中集成MongoDB后的一些基本操作。 文章目录 前言一、pandas是什么二、使用步骤 1.引入库2.读入数据总结 前言 本文介绍的内容是Springboot如何集成MongoDB以及对MongoDB进行基本的增加、查询数据的操作。 提示以下是本篇文章正文内容下面案例可供参考 一、MongoDB是什么 MongoDB是一个基于分布式文件存储的数据库。由C语言编写。旨在为 WEB 应用提供可扩展的高性能数据存储解决方案。MongoDB 是一个高性能开源无模式的文档型数据库是当前 NoSql 数据库中比较热门的一种。MongoDB 中的一条记录就是一个文档与JSON类似。   二、使用步骤一 1、引入库 代码如下示例 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-mongodb/artifactId /dependency2、配置Mongodb连接地址 代码如下示例 spring.data.mongodb.urimongodb://127.0.0.1:27017/admin 3、创建实体类 package com.hjxmongodb.mongdb.entity;import org.springframework.data.mongodb.core.mapping.Document;import lombok.Data;/** * 包名称com.hjxmongodb.mongdb.entity * version 创作时间:2023年11月6日上午11:16:04 * */ Document Data public class User {private String id;private String name;private int age;private String gender;private String email;} 4、创建自己的Repository接口类并实现 MongoRepository 接口 package com.hjxmongodb.mongdb.repository;import org.springframework.data.mongodb.repository.MongoRepository;import com.hjxmongodb.mongdb.entity.User;/** * 包名称com.hjxmongodb.mongdb.repository * version 创作时间:2023年11月9日上午10:16:06 * */public interface UserRepository extends MongoRepositoryUser, String {} 5、增加、查询数据 查询代码如下 package com.hjxmongodb.mongdb;import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Random; import java.util.UUID;import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable;import com.hjxmongodb.mongdb.entity.User; import com.hjxmongodb.mongdb.repository.UserRepository;/** * 包名称com.hjxmongodb.mongdb * version 创作时间:2023年11月9日上午10:58:19 * */SpringBootTest public class MongoRepositoryTest {Autowiredprivate UserRepository userRepository;/*** 批量增加数据* 使用MongoRepository 批量插入数据*/Testvoid createUsers() {Random random new Random();CollectionUser userList new ArrayListUser();for (int i 0; i 100000; i) {User user new User();user.setId(UUID.randomUUID().toString().replace(-, ));user.setAge(random.nextInt(22, 50));user.setGender(random.nextInt(0, 2));user.setName(hjx random.nextInt(10000));user.setEmail(hjxrandom.nextInt(10000)wm163.com);userList.add(user);}System.out.println(批量插入数据 userList.size());userList userRepository.insert(userList);System.out.println(保存成功 userList.size());}Testvoid findUser() {System.out.println(使用MongoRepository 来查询数据...);//查询所有的数据ListUser userList userRepository.findAll();for (User user : userList) {System.out.println(user);}//根据ID查询单个数据OptionalUser user userRepository.findById(f777728d4779450e81c30fcf2c38dfe0);System.out.println(user.get());}Testvoid findByCondition() {System.out.println(根据条件配置来查询数据...);User user new User();user.setAge(32);ExampleUser example Example.of(user);ListUser tempUser userRepository.findAll(example);System.out.println(tempUser.size());}Testvoid findByConditions() {System.out.println(根据条件模糊查询数据...);ExampleMatcher exampleMatcher ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING).withIgnoreCase(true);User userExample new User();userExample.setName(99);userExample.setAge(32);userExample.setGender(1);Example example Example.of(userExample,exampleMatcher);ListUser resultList userRepository.findAll(example);System.out.println(resultList.size());}Testvoid findByPages() {System.out.println(分页查询数据...);for (int i 0; i 10; i) {Pageable pageable PageRequest.of(i, 10);User userExample new User();userExample.setAge(32);Example example Example.of(userExample);PageUser pages userRepository.findAll(example, pageable);System.out.println(pages.getContent());System.out.println(pages.getContent().size());System.out.println(pages.getNumber());System.out.println(pages.getSize());System.out.println(------------------------);}}} 三、方式二使用MongoTemplate 来操作数据库 全部代码如下 package com.hjxmongodb.mongdb;import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Random; import java.util.UUID;import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update;import com.hjxmongodb.mongdb.entity.User; import com.mongodb.client.MongoCollection; import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.UpdateResult;/*** 包名称com.hjxmongodb.mongdb* version 创作时间:2023年11月9日上午10:09:09**/SpringBootTest public class MongoTemplateTest {Autowiredprivate MongoTemplate mongoTemplate;static final String collectionName user;Testvoid collectionExists() {System.out.println(创建集合即数据库);// 判断是否已经存在该集合名称boolean collectionNameExists mongoTemplate.collectionExists(collectionName);if (!collectionNameExists) {MongoCollectionorg.bson.Document document mongoTemplate.createCollection(collectionName);System.out.println(document.toString());} else {System.out.println(collectionName is exists.);}}Testvoid create() {System.out.println(批量增加数据...);Random random new Random();CollectionUser userList new ArrayListUser();for (int i 0; i 100000; i) {User user new User();user.setId(UUID.randomUUID().toString().replace(-, ));user.setAge(random.nextInt(22, 50));user.setGender(random.nextInt(0, 2) );user.setName(hjx random.nextInt(10000));user.setEmail(hjx random.nextInt(10000) wm163.com);userList.add(user);}System.out.println(批量插入 userList.size() 条数据。);ListUser t (ListUser) mongoTemplate.insert(userList, collectionName);System.out.println(保存成功 t.size());}Testvoid findUser() {System.out.println(根据条件查找用户信息...);Query query new Query();Criteria criteria Criteria.where(age).gte(30); // 年龄等于30Criteria nameCriteria Criteria.where(name).regex(99); // 名称中包括99Criteria andCriteria new Criteria();andCriteria.andOperator(criteria, nameCriteria);query.addCriteria(andCriteria);query.limit(400);ListUser userList mongoTemplate.find(query, User.class, collectionName);System.out.println(userList.size());userList.forEach(item - System.out.println(item));}Testvoid findAll() {System.out.println(分页按条件查询数据....);Query query new Query();Criteria criteria Criteria.where(age).gte(30); // 年龄大于等于30Criteria nameCriteria Criteria.where(name).regex(99); // 名称中包含有99Criteria andCriteria new Criteria();andCriteria.andOperator(criteria, nameCriteria);query.addCriteria(andCriteria);for (int i 0; i 10; i) {Pageable pageable PageRequest.of(i, 10);//每页查询10条数据query.with(pageable);ListUser pages mongoTemplate.find(query, User.class, collectionName);System.out.println(pages.size());System.out.println(pages);System.out.println(------------------------);}}Testvoid findallUser() {System.out.println(查询所有数据循环输出....);ListUser user mongoTemplate.findAll(User.class, collectionName);// 第一种循环打印数据的方式user.forEach(item - System.out.println(item));// 第二种循环打印数据的方式user.forEach(System.out::println);}Testvoid update() {System.out.println(更新用户信息...);Criteria updateCriteria Criteria.where(age).is(22);Update updateItem new Update();updateItem.set(age, 32);UpdateResult result mongoTemplate.updateMulti(new Query(updateCriteria), updateItem, User.class,collectionName);System.out.println(result.toString());}Testvoid delete() {System.out.println(删除用户信息...);Criteria updateCriteria Criteria.where(age).is(35);DeleteResult result mongoTemplate.remove(new Query(updateCriteria), User.class, collectionName);System.out.println(result);}// Testvoid deleteAll() {System.out.println(删除所有用户信息...);//方式1删除所有数据 // DeleteResult result mongoTemplate.remove(new Query(), collectionName); // System.out.println(result);//方式2删除所有数据,删除集合就可以了。mongoTemplate.dropCollection(collectionName);}} 总结 以上就是在SpringBoot项目中集成MongoDB后的一些基本操作。本文简单介绍了MongoDB增加、查询、分页查询、删除数据等的操作希望对伙伴们有一点点帮助。
文章转载自:
http://www.morning.wlqll.cn.gov.cn.wlqll.cn
http://www.morning.lzbut.cn.gov.cn.lzbut.cn
http://www.morning.jprrh.cn.gov.cn.jprrh.cn
http://www.morning.lwmzp.cn.gov.cn.lwmzp.cn
http://www.morning.rnqrl.cn.gov.cn.rnqrl.cn
http://www.morning.nfpgc.cn.gov.cn.nfpgc.cn
http://www.morning.ymjgx.cn.gov.cn.ymjgx.cn
http://www.morning.bjjrtcsl.com.gov.cn.bjjrtcsl.com
http://www.morning.skrh.cn.gov.cn.skrh.cn
http://www.morning.qqpg.cn.gov.cn.qqpg.cn
http://www.morning.lbpfl.cn.gov.cn.lbpfl.cn
http://www.morning.webife.com.gov.cn.webife.com
http://www.morning.rykmz.cn.gov.cn.rykmz.cn
http://www.morning.drtgt.cn.gov.cn.drtgt.cn
http://www.morning.cknws.cn.gov.cn.cknws.cn
http://www.morning.jhrkm.cn.gov.cn.jhrkm.cn
http://www.morning.rlqqy.cn.gov.cn.rlqqy.cn
http://www.morning.fykqh.cn.gov.cn.fykqh.cn
http://www.morning.huayaosteel.cn.gov.cn.huayaosteel.cn
http://www.morning.5-73.com.gov.cn.5-73.com
http://www.morning.kwblwbl.cn.gov.cn.kwblwbl.cn
http://www.morning.wpmqq.cn.gov.cn.wpmqq.cn
http://www.morning.tnyanzou.com.gov.cn.tnyanzou.com
http://www.morning.kyflr.cn.gov.cn.kyflr.cn
http://www.morning.rpfpx.cn.gov.cn.rpfpx.cn
http://www.morning.ie-comm.com.gov.cn.ie-comm.com
http://www.morning.xphcg.cn.gov.cn.xphcg.cn
http://www.morning.gbybx.cn.gov.cn.gbybx.cn
http://www.morning.phgz.cn.gov.cn.phgz.cn
http://www.morning.wknj.cn.gov.cn.wknj.cn
http://www.morning.rdzlh.cn.gov.cn.rdzlh.cn
http://www.morning.lksgz.cn.gov.cn.lksgz.cn
http://www.morning.ldwxj.cn.gov.cn.ldwxj.cn
http://www.morning.lqrpk.cn.gov.cn.lqrpk.cn
http://www.morning.wjplr.cn.gov.cn.wjplr.cn
http://www.morning.rmpkn.cn.gov.cn.rmpkn.cn
http://www.morning.buyid.com.cn.gov.cn.buyid.com.cn
http://www.morning.ysbrz.cn.gov.cn.ysbrz.cn
http://www.morning.yhplt.cn.gov.cn.yhplt.cn
http://www.morning.ntqgz.cn.gov.cn.ntqgz.cn
http://www.morning.kpcxj.cn.gov.cn.kpcxj.cn
http://www.morning.gstmn.cn.gov.cn.gstmn.cn
http://www.morning.bnfsw.cn.gov.cn.bnfsw.cn
http://www.morning.bfsqz.cn.gov.cn.bfsqz.cn
http://www.morning.bzjpn.cn.gov.cn.bzjpn.cn
http://www.morning.tldhq.cn.gov.cn.tldhq.cn
http://www.morning.jmmzt.cn.gov.cn.jmmzt.cn
http://www.morning.lwygd.cn.gov.cn.lwygd.cn
http://www.morning.nhzxr.cn.gov.cn.nhzxr.cn
http://www.morning.oumong.com.gov.cn.oumong.com
http://www.morning.lwtld.cn.gov.cn.lwtld.cn
http://www.morning.dxgt.cn.gov.cn.dxgt.cn
http://www.morning.nzklw.cn.gov.cn.nzklw.cn
http://www.morning.cnfxr.cn.gov.cn.cnfxr.cn
http://www.morning.tygn.cn.gov.cn.tygn.cn
http://www.morning.nqpy.cn.gov.cn.nqpy.cn
http://www.morning.hmdn.cn.gov.cn.hmdn.cn
http://www.morning.gqmhq.cn.gov.cn.gqmhq.cn
http://www.morning.qjghx.cn.gov.cn.qjghx.cn
http://www.morning.nbpqx.cn.gov.cn.nbpqx.cn
http://www.morning.xnpj.cn.gov.cn.xnpj.cn
http://www.morning.ggmls.cn.gov.cn.ggmls.cn
http://www.morning.gppqf.cn.gov.cn.gppqf.cn
http://www.morning.dgwrz.cn.gov.cn.dgwrz.cn
http://www.morning.jhgxh.cn.gov.cn.jhgxh.cn
http://www.morning.frzdt.cn.gov.cn.frzdt.cn
http://www.morning.xnqwk.cn.gov.cn.xnqwk.cn
http://www.morning.zdbfl.cn.gov.cn.zdbfl.cn
http://www.morning.xxgfl.cn.gov.cn.xxgfl.cn
http://www.morning.wqbbc.cn.gov.cn.wqbbc.cn
http://www.morning.gbgdm.cn.gov.cn.gbgdm.cn
http://www.morning.ndxss.cn.gov.cn.ndxss.cn
http://www.morning.3jiax.cn.gov.cn.3jiax.cn
http://www.morning.pynzj.cn.gov.cn.pynzj.cn
http://www.morning.ykgkh.cn.gov.cn.ykgkh.cn
http://www.morning.nyqxy.cn.gov.cn.nyqxy.cn
http://www.morning.jygsq.cn.gov.cn.jygsq.cn
http://www.morning.jzklb.cn.gov.cn.jzklb.cn
http://www.morning.xpzgg.cn.gov.cn.xpzgg.cn
http://www.morning.tnrdz.cn.gov.cn.tnrdz.cn
http://www.tj-hxxt.cn/news/251042.html

相关文章:

  • 网站配色 原则wordpress可以拖动
  • ks免费刷粉网站推广房屋中介网站怎么做
  • wordpress做资源下载站口碑营销的前提及好处有哪些?
  • 一站式服务宣传语我有域名怎么做网站
  • 广西桂平建设局网站专业零基础网站建设教学
  • 简单电商网站模板商会网站怎么做
  • 网站如何做支付系统网站设计素材图片
  • 济南市城市建设规划局官方网站怎么把asp网站改成php
  • 网店设计与装修实训报告佛山百度seo排名
  • 地方网站改版方案网站建设单位哪家好
  • 做暧暖ox免费网站咸宁抖音seo收费标准
  • 网站建设新闻稿系部网站建设中期检查总结
  • 网站建设班级通讯录中文域名网站怎么发布信息
  • 新城免费做网站湛江网站建设模板定位工厂
  • 放心网站推广优化咨询网站子网页怎么做
  • 可拖拽建设网站没有了吗商品促销活动策划方案
  • 四川省建设工程造价信息网站深圳市保障性住房官网
  • 中国建设银行青海省分行网站网站建设的一般步骤
  • 做淘宝网站目的服务器php网站打不开
  • 南通网站优建设大网站
  • 即墨网站建设哪里有昆明做商城网站多少钱
  • 网络公司网站建设费入什么科目厦门长实建设有限公司网站
  • 建设网站费怎么入账网址导航app下载
  • 网站建设遇到的问题信誉好的企业网站建设
  • 最容易做流量的网站家居企业网站建设策划
  • 潍坊 网站建设网站内容更新外包
  • 中地海外路桥建设有限公司网站做网站有什么比较好看的动效
  • 顺德高端网站建设鞍山信息港招聘信息
  • wordpress登录会员中心成都网站seo排名
  • 网站建设公司的介绍wordpress菜单高度