首页 > 其他分享 >SpringBoot官方笔记5Data

SpringBoot官方笔记5Data

时间:2023-07-17 22:56:13浏览次数:40  
标签:SpringBoot 5Data spring 笔记 name mongodb Spring data String

Spring Boot integrates with a number of data technologies, both SQL and NoSQL.

SQL Databases

Spring Data provides an additional level of functionality: creating Repository implementations directly from interfaces and using conventions to generate queries from your method names.

The spring-boot-starter-data-jpa POM provides a quick way to get started. It provides the following key dependencies:

  • Hibernate: One of the most popular JPA implementations.

  • Spring Data JPA: Helps you to implement JPA-based repositories.

  • Spring ORM: Core ORM support from the Spring Framework.

A typical entity class resembles the following example:

import java.io.Serializable;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;

@Entity
public class City implements Serializable {

    @Id
    @GeneratedValue
    private Long id;

    @Column(nullable = false)
    private String name;

    @Column(nullable = false)
    private String state;

    // ... additional members, often include @OneToMany mappings

    protected City() {
        // no-args constructor required by JPA spec
        // this one is protected since it should not be used directly
    }

    public City(String name, String state) {
        this.name = name;
        this.state = state;
    }

    public String getName() {
        return this.name;
    }

    public String getState() {
        return this.state;
    }

    // ... etc

}

Working with NoSQL Technologies

Redis

Redis is a cache, message broker, and richly-featured key-value store. Spring Boot offers basic auto-configuration for the Lettuceand Jedis client libraries and the abstractions on top of them provided by Spring Data Redis.

By default, the instance tries to connect to a Redis server at localhost:6379.

spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.database=0
spring.data.redis.username=user
spring.data.redis.password=secret

MongoDB

The auto-configured MongoClient is created using a MongoClientSettings bean.

spring.data.mongodb.host=mongoserver1.example.com
spring.data.mongodb.port=27017
spring.data.mongodb.additional-hosts[0]=mongoserver2.example.com:23456
spring.data.mongodb.database=test
spring.data.mongodb.username=user
spring.data.mongodb.password=secret

Elasticsearch

Spring Boot supports several clients:

  • The official low-level REST client

  • The official Java API client

  • The ReactiveElasticsearchClient provided by Spring Data Elasticsearch

spring.elasticsearch.uris=https://search.example.com:9200
spring.elasticsearch.socket-timeout=10s
spring.elasticsearch.username=user
spring.elasticsearch.password=secret

InfluxDB

InfluxDB is an open-source time series database optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet-of-Things sensor data, and real-time analytics.

spring.influx.url=https://172.0.0.1:8086

参考资料:

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#data

标签:SpringBoot,5Data,spring,笔记,name,mongodb,Spring,data,String
From: https://www.cnblogs.com/df888/p/17561523.html

相关文章

  • SpringBoot官方笔记8其他
    ContainerImagesFROMeclipse-temurin:17-jreasbuilderWORKDIRapplicationARGJAR_FILE=target/*.jarCOPY${JAR_FILE}application.jarRUNjava-Djarmode=layertools-jarapplication.jarextractFROMeclipse-temurin:17-jreWORKDIRapplicationCOPY--from=......
  • 决策单调性优化DP 学习笔记 & P4767 [IOI2000] 邮局 题解
    0.题面题目描述高速公路旁边有一些村庄。高速公路表示为整数轴,每个村庄的位置用单个整数坐标标识。没有两个在同样地方的村庄。两个位置之间的距离是其整数坐标差的绝对值。邮局将建在一些,但不一定是所有的村庄中。为了建立邮局,应选择他们建造的位置,使每个村庄与其最近的邮局......
  • 组合数学学习笔记
    组合数学学习笔记组合数学常用公式基本公式排列:\[A_{n}^r=\frac{n!}{(n-r)!}\]组合:\[C_{n}^r=\frac{n!}{r!(n-r)!}\\\dbinom{n}{r}=\frac{n!}{r!(n-r)!}\]组合公式杨辉恒等式......
  • 第一篇博客 练习typora笔记
    学习MarkDown字体helloworld!helloworld!helloworld!helloworld! 引用 乐交诤友不交损友 分割线 图片  超链接点击跳转到百度 列表ABC 无序列表ABC 列表姓名性別年齡張三男18 代碼publicvoid......
  • springboot下使用rabbitMQ之开发配置方式(一)
    springboot下使用rabbitMQ之开发配置方式(一)距离上次发布博客已经小一年了,这次...嗯,没错,我又回来啦.........
  • C++笔记(2)——函数
    六.函数6.1函数基础一个典型的函数(function)定义包括:返回类型(returntype)、函数名字,由0或多个形参(parameter)组成的列表以及函数体。我们通过调用运算符来执行函数,形式为"()"。函数调用完成两项工作:一是用实参初始化函数对应的形参,二是将控制权转移给被调用函数。此时,主调......
  • mysql 笔记
    行转列: namecoursegradezhangsanjava20zhangsanc#60zhangsanpython40lisijava109lisic#30lisipython20wangwujava33 selectname,sum(casewhencourse='java'thengradeend)as'java',sum(casewhen......
  • 小红书获得小红书笔记详情 API 返回值说明
    ​ item_get_video-获得小红书笔记详情 注册开通smallredbook.item_get_video公共参数名称类型必须描述keyString是调用key(必须以GET方式拼接在URL中)secretString是调用密钥api_nameString是API接口名称(包括在请求地址中)[item_search,item_get,item_s......
  • Learning hard C#学习笔记——读书笔记 03
    C#是面向对象的语言,每次到这里就会有一个问题,什么是对象,其实一句话就可以解释,那就是——万物皆是对象,这句话就像“如来”一样抽象,其实,我们无须在这上面耗费太大的精力,我们随着学习的深入,对象的概念自然会深入到脑海中所有面向对象的编程语言都有以下三个基础特征封装——把客......
  • Learning hard C#学习笔记——读书笔记 02
    每每说到类,不得不介绍的就是类的定义,它是一个抽象的概念,它是一个模板,制造对象的模板1.定义一个类classPreson{//类的成员变量}默认情况下,class关键字没有显式的使用internal修饰符来定义类,但是没有必要这样做,默认的修饰符就是internal除了internal这个权限修饰......