[完结19章]SpringBoot开发双11商品服务系统

kaidnxhd2023 · · 408 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
今天给大家分享一下关于SpringBoot开发双11商品服务系统的整个流程,我将深度还原大厂实习期技术成长全流程,让你收获大厂项目开发全流程与实战经验,具备应对大流量场景问题的解决能力,全面助力提升实习/转正/跳槽表现力与成功率。 以下是参考资料下载: 网盘地址:https://pan.baidu.com/s/1QNf3FbzlswJd_DU3FC64nw 提取码:q61x 腾讯微云下载地址:https://share.weiyun.com/o6TKslZV 密码:qn8bim Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。 目的 让大家更容易使用 spring,更容易集成各种常用的中间件、开源软件。 SpringBoot 基于 Spring 开发, SpringBoot 本身并不提供 Spring 框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于 Spring 框架的应用程序。 SpringBoot 不是用来替代 spring 的解决方案,而是和 spring 框架紧密结合提升 spring 开发者体验的工具。 准备测试数据 我们先导入准备好的测试数据,这个测试数据是一份商品数据。 字段包含商品id,name(商品名) last_month_sales(最近一个月的销量) favorites(收藏数)这几个字段,我们主要是通过商品名来搜索。 首先我先先创建一个商品索引 PUT goods { "settings": { "number_of_shards": 1, "number_of_replicas": 0 }, "mappings": { "properties": { "id": { "type": "keyword", "doc_values": false, "norms": false, "similarity": "boolean" }, "name": { "type": "text" }, "price": { "type": "double" }, "last_month_sales": { "type": "long" }, "favorites": { "type": "long" }, "year":{ "type": "short" } } } } 千里之行,始于足下。想要舒舒服服地使用Spring框架,就要把它的开发环境配置好,这对它好,也对我好。 1. jdk 的配置 使用 IDEA 进行开发,在 IDEA 中配置 jdk 的方式很简单,打开 File->Project Structure选择 SDKs。 在 JDK home path 中选择本地 jdk 的安装目录。 在 Name 中为 jdk 自定义名字通过以上三步骤,即可导入本地安装的 jdk。如果是使用 STS 或者 eclipse 可以通过两步骤添加: window->preference->java->Instralled JRES 来添加本地 jdk。 window-->preference-->java-->Compiler 选择 jre,和 jdk 保持一致。 PUT test_index/_doc/1 { "string_field":"imooc", "int_field": 100, "float_field":3.14, "bool_field":true, "date_field":"2022/03/16", "obj_field":{"key1":"value1","key2":100}, "array_field1":[100,3.14], "array_field2":[100,"200"], "array_field3":["2022/03/16","100"], "array_field4":["100","2022/03/16"], "null_field":null } 创建 Spring Boot 项目后需要进行 maven 配置。打开 File->settings,搜索 maven,配置一下本地的 maven 信息。在 Maven home directory 中选择本地 Maven 的安装路径;在 User settings file 中选择本地 Maven 的配置文件所在路径。在配置文件中配置一下国内阿里的镜像,这样在下载 maven 依赖时,速度会变得很快。 { "test_index" : { "mappings" : { "properties" : { "array_field" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "bool_field" : { "type" : "boolean" }, "date_field" : { "type" : "date", "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis" }, "float_field" : { "type" : "float" }, "int_field" : { "type" : "long" }, "obj_field" : { "properties" : { "key1" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } }, "key2" : { "type" : "long" } } }, "string_field" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword", "ignore_above" : 256 } } } } } } } 从以上结果中,我们可以看到 Spring Boot 通过MVN方式自动为项目配置了对应的 springframework、logging、jackson 以及 Tomcat 等依赖,而这些正是我们在开发 Web 项目时所需要的。 那么细心的同学可能会发现一个问题,即在以上 pom.xml 的配置中,引入依赖 spring-boot-starter-web 时,并没有指明其版本(version),但在依赖列表中,我们却看到所有的依赖都具有版本信息,那么这些版本信息是在哪里控制的呢? { "_index" : "test_index", "_id" : "1", "_version" : 1, "_seq_no" : 0, "_primary_term" : 1, "found" : true, "_source" : { "string_field" : "Chan", "int_field" : 100, "int_string_field" : "100", "float_field" : 3.14, "bool_field" : true, "date_field" : "2022/03/16", "obj_field" : { "key1" : "value1", "key2" : 100 }, "array_field" : [ "value1", "100" ], "null_field" : null } } spring-boot-starter-parent 是所有 Spring Boot 项目的父级依赖,它被称为 Spring Boot 的版本管理中心,可以对项目内的部分常用依赖进行统一管理。 <parent>             <groupId>org.springframework.boot</groupId>             <artifactId>spring-boot-starter-parent</artifactId>             <version>2.5.6</version>             <relativePath/>  </parent> Spring Boot 项目可以通过继承 spring-boot-starter-parent 来获得一些缺省的配置内容,它主要提供了以下特性: 默认 JDK 版本(Java 8) 默认字符集(UTF-8) 依赖管理功能 资源过滤 默认插件配置识别  application.properties 或 application.yml 类型的配置文件 DELETE test_index PUT test_index { "mappings": { "dynamic":false } } GET test_index/_search { "query": { "term": { "field1.field2": { "value": "imooc ES" } } } } GET test_index/_doc/4 DELETE test_index PUT test_index { "mappings": { "dynamic":"strict" } } POST test_index/_doc/2 { "field1":{ "field2":"imooc ES" } } GET test_index/_search { "query": { "term": { "field1.field2": { "value": "imooc ES" } } } } GET test_index/_doc/4 以下就是本文的全部内容,感谢大家观看
408 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传