SpringData JPA 整合Springboot
1.导入依赖
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>springdata</artifactId><groupId>com.kuang</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>springboot-jpa</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-- 声明springboot的版本号 --><spring-boot.version>2.2.9.RELEASE</spring-boot.version></properties><!-- 引入springboot官方提供的所有依赖的版本号定义,如果项目中使用相关依赖,可以不必写版本号了--><dependencyManagement><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><dependencies><!-- 引入springboot的web项目的依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
<!-- data - jpa 启动器 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.47</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency><!-- druid连接--><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.6</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency></dependencies></project>
2.yml
spring:datasource:driver-class-name: com.mysql.jdbc.Driverusername: rootpassword: 2001url: jdbc:mysql://localhost:3306/springdata_jpa?useSSL=true&useUnicode=true&characterEncoding=utf8type: com.alibaba.druid.pool.DruidDataSourcejpa:hibernate:ddl-auto: update #数据库表的生成策略show-sql: true #是否显示SQLgenerate-ddl: true #是否生成建表语句打印在控制台上
3.CustomerRepository 接口
package com.kuang.springdata.repositories;import com.kuang.springdata.pojo.Customer;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Component;public interface CustomerRepository extends PagingAndSortingRepository<Customer,Long> {
}
4.service
package com.kuang.springdata.service;import com.kuang.springdata.pojo.Customer;public interface CustomerService {Iterable<Customer> getAll();
}
package com.kuang.springdata.service;import com.kuang.springdata.pojo.Customer;
import com.kuang.springdata.repositories.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Service
public class CustomerServiceImpl implements CustomerService{@Autowiredprivate CustomerRepository customerRepository;@Overridepublic Iterable<Customer> getAll() {return customerRepository.findAll();}
}
5.Controller
package com.kuang.springdata.controller;import com.kuang.springdata.pojo.Customer;
import com.kuang.springdata.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class CustomerController {@Autowiredprivate CustomerService customerService;@RequestMapping("/customer/all")public Iterable<Customer> getAll(){Iterable<Customer> iterable=customerService.getAll();return iterable;}
}
6.运行
7.可以配置的选项

相关文章:
SpringData JPA 整合Springboot
1.导入依赖 <?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…...
打工人副业变现秘籍,某多/某手变现底层引擎-Stable Diffusion 黑白老照片上色修复
在这个时代,我们习惯于拥有高清、色彩丰富的照片,然而,那些古老的黑白色老照片由于年代的久远,往往会出现模糊、破损等现象。 那么今天要给大家介绍的是,用 Stable Diffusion 来修复老照片。 前段时间 ControlNet 的除了上线了“IP-Adapter”模型以外还增加另一个…...
第十三章总结
一.泛型 1.定义泛型类 泛型机制语法: 类名<T> 其中,T是泛型的名称,代表某一种类型。 【例13.6】创建带泛型的图书类 代码: 结果: 2.泛型的常规用法 (1)定义泛型类时声明多个变量 class MyClass<T1,T2…...
大模型应用_PrivateGPT
https://github.com/imartinez/privateGPT 1 功能 整体功能,想解决什么问题 搭建完整的 RAG 系统,与 FastGPT相比,界面比较简单。但是底层支持比较丰富,可用于知识库的完全本地部署,包含大模型和向量库。适用于保密级…...
[Android] ubuntu虚拟机上搭建 Waydroid 环境
1.安装虚拟机 略 2.安装waydroid Ubuntu/Debian and derivatives For Droidian and Ubuntu Touch, skip directly to the last step Install pre-requisites sudo apt install curl ca-certificates -y Add the official repository curl https://repo.waydro.id | sudo…...
LeedCode刷题---滑动窗口问题(二)
顾得泉:个人主页 个人专栏:《Linux操作系统》 《C/C》 《LeedCode刷题》 键盘敲烂,年薪百万! 一、将X减到0的最小操作数 题目链接:将 x 减到 0 的最小操作数 题目描述 给你一个整数数组 nums 和一个整数 x 。每一…...
pycharm依赖管理(不要用pip freeze)
在使用python虚拟环境时,可以使用requirements.txt来管理当前项目的依赖。 注意,不要用 pip freeze > requirements.txt 这个命令,因为它会引入很多无关的包。 可以使用 pipreqs ./ --encodingutf-8 ./ 表示当前项目的目录࿰…...
[Kafka 常见面试题]如何保证消息的不重复不丢失
文章目录 Kafka1. Kafka如何保证不丢失消息?生产者数据的不丢失消费者数据的不丢失Kafka集群中的broker的数据不丢失 2. Kafka中的消息是否会丢失和重复消费?1. 消息发送2. 消息消费 3. Kafka 的设计是什么样的呢?4. 数据传输的事务定义有哪三…...
Java中System.setProperty()用法
Java中System.setProperty()用法 大家好,我是免费搭建查券返利机器人赚佣金就用微赚淘客系统3.0的小编,也是冬天不穿秋裤,天冷也要风度的程序猿!今天,让我们一起深入了解Java中的System.setProperty()方法,…...
Eclipse 自动生成注解,如果是IDEA可以参考编译器自带模版进行修改
IDEA添加自动注解 左上角选择 File -> Settings -> Editor -> File and Code Templates; 1、添加class文件自动注解: /*** <b>Function: </b> todo* program: ${NAME}* Package: ${PACKAGE_NAME}* author: Jerry* date: ${YEA…...
微信小程序vant安装使用过程中遇到无法构建npm的问题
官网地址,然而如果完全按照这个教程来,实际上是缺少步骤的,需要补充一些步骤(参考https://www.bilibili.com/video/BV1vL41127Er) # 这步init就是补充的 npm init npm i vant/weapp -S --production# 剩下的按照vant的…...
[python]用python获取EXCEL文件内容并保存到DBC
目录 关键词平台说明背景所需库实现过程方法1.1.安装相关库2.代码实现 关键词 python、excel、DBC、openpyxl 平台说明 项目Valuepython版本3.6 背景 在搭建自动化测试平台的时候经常会提取DBC文件中的信息并保存为excel或者其他文件格式,用于自动化测试。本文…...
Spring Boot 如何配置 log4j2
Log4j2 介绍 Spring Boot 中默认使用 Logback 作为日志框架,接下来我们将学习如何在 Spring Boot 中集成与配置 Log4j2。在配置之前,我们需要知道的是 Log4j2 是 Log4j 的升级版,它在 Log4j 的基础上做了诸多改进: 异步日志&…...
如何安装docker
安装Docker的步骤取决于您使用的操作系统。以下是常见操作系统上安装Docker的基本步骤: 对于Linux: 更新软件包索引: sudo apt-get update安装允许apt通过HTTPS使用仓库的包: sudo apt-get install apt-transport-https ca-certificates cur…...
Linux 之 性能优化
uptime $ uptime -p up 1 week, 1 day, 21 hours, 27 minutes$ uptime12:04:11 up 8 days, 21:27, 1 user, load average: 0.54, 0.32, 0.23“12:04:11” 表示当前时间“up 8 days, 21:27,” 表示运行了多长时间“load average: 0.54, 0.32, 0.23”“1 user” 表示 正在登录…...
用Go汇编实现一个快速排序算法
本代码全网首发,使用Go plan9 windows arm64汇编,实现基础版快速排序算法。 未引入随机因子的快速排序的普通Go代码长这样。 func QuickSort(arr []int) {if len(arr) < 1 {return}base, l, r : arr[0], 0, len(arr)-1for i : 1; i < r; {if arr…...
Spring-整合MyBatis
依赖 <dependencies><!--提供数据源--><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>5.1.9.RELEASE</version></dependency><!--提供sqlSessionFactory…...
sql宽字节注入
magic_quotes_gpc(魔术引号开关) https://www.cnblogs.com/timelesszhuang/p/3726736.html magic_quotes_gpc函数在php中的作用是判断解析用户提交的数据,如包括有:post、get、cookie过来的数据增加转义字符“\”,以…...
开源 LLM 微调训练指南:如何打造属于自己的 LLM 模型
一、介绍 今天我们来聊一聊关于LLM的微调训练,LLM应该算是目前当之无愧的最有影响力的AI技术。尽管它只是一个语言模型,但它具备理解和生成人类语言的能力,非常厉害!它可以革新各个行业,包括自然语言处理、机器翻译、…...
Android hilt使用
一,添加依赖库 添加依赖库app build.gradle.kts implementation("com.google.dagger:hilt-android:2.49")annotationProcessor("com.google.dagger:hilt-android:2.49")annotationProcessor("com.google.dagger:hilt-compiler:2.49"…...
UVa 12117 ACM Puzzles
题目描述 ACM\texttt{ACM}ACM(儿童机器协会)计划为儿童设计一种新型拼图。所有拼图的尺寸都是 3N3 \times N3N ,并使用 222222 种特定的拼图块(某些块可以重复使用)。为了防止假冒产品,ACM\texttt{ACM}ACM …...
从零开始:使用PHPStudy+Verilog搭建一生一芯双控开关实验环境
从零开始:使用PHPStudyVerilog搭建一生一芯双控开关实验环境 在数字电路与嵌入式系统教学中,双控开关实验是理解硬件描述语言与FPGA开发的重要入门项目。本文将手把手带你搭建完整的实验环境,从本地服务器配置到Verilog代码实现,最…...
SMPL转BVH避坑指南:解决Python格式转换中的常见问题
SMPL转BVH实战指南:Python开发者必知的7个技术陷阱与解决方案 当你在深夜的显示器前盯着报错的Python终端,第17次尝试将SMPL模型转换为BVH格式时,是否也经历过那种"明明按照教程操作却总是报错"的崩溃感?作为处理过上百…...
【数据结构与算法】LIS专项练习
LIS 专项练习题目编号说明【模板】最长上升子序列B3637纯LIS模板,n≤10⁵,用二分导弹拦截P1020LIS 贪心,经典题合唱队形P1091LIS LDS 组合友好城市P2782排序后转LIS1.#include<iostream> #include<vector> using namespace std…...
Deepsort跟踪器在车辆检测中的表现如何?我用MOT16数据集做了这些实验
DeepSORT在车辆跟踪中的实战评估:从MOT16数据集改造到指标分析 当目标跟踪技术从学术研究走向工业落地时,车辆跟踪成为智能交通和自动驾驶领域的关键环节。本文将带您深入探索如何将原本针对行人跟踪设计的MOT16数据集改造为车辆跟踪评估基准,…...
销售客户推荐难?RPA自动找相似客户,拓展更易成功
RPA技术在客户推荐中的应用RPA(Robotic Process Automation)技术能自动化执行重复性任务,包括客户数据分析和推荐。通过分析现有客户数据,RPA可以识别相似客户特征,帮助销售团队精准定位潜在客户。数据收集与清洗RPA工…...
Qwen3-TTS-12Hz-1.7B实战教程:服务首次加载超时问题的3种解决方法
Qwen3-TTS-12Hz-1.7B实战教程:服务首次加载超时问题的3种解决方法 1. 引言 你是否遇到过这样的情况:兴致勃勃地部署了Qwen3-TTS语音合成服务,却在首次启动时卡在加载界面,进度条一动不动?别担心,这是很多…...
Qwen3-VL:30B部署常见问题解决:Web空白页、API连接超时、模型加载失败全解析
Qwen3-VL:30B部署常见问题解决:Web空白页、API连接超时、模型加载失败全解析 在上一篇教程《星图平台快速搭建 Clawdbot:私有化本地 Qwen3-VL:30B 并接入飞书》中,我们成功在星图AI云平台上部署了强大的多模态大模型Qwen3-VL:30B,…...
从‘素模’到‘高仿’:我是如何用Blender和PS给Tianbot Mini小车激光雷达‘化妆’并跑进Gazebo的
从‘素模’到‘高仿’:Blender与PS联袂打造Gazebo仿真视觉盛宴 第一次在Gazebo中加载Tianbot Mini的激光雷达模型时,那种"塑料玩具"般的质感让我瞬间理解了为什么专业团队要花重金做3D视觉设计。作为RoboMaster参赛队的后勤技术支持࿰…...
LM339和LM393比较器实战:为什么你的电路响应速度总比别人慢?
LM339与LM393比较器实战:提升电路响应速度的五大关键设计 在电子设计领域,响应速度往往是决定系统性能的关键指标之一。许多工程师在使用LM339和LM393这类经典比较器时,常会遇到电路响应不如预期的问题。本文将深入探讨影响比较器响应速度的核…...
