Spring Boot MySQL JPA Hibernate Restful CRUD API Tutorial

在这里插入图片描述

Spring Boot has taken Spring framework to the next level. It has drastically reduced the configuration and setup time required for spring projects.

Spring Boot将Spring框架提升到了一个新的高度。它大大减少了Spring项目所需的配置和设置时间

You can setup a project with almost zero configuration and start building the things that actually matter to your application.

您可以使用几乎为零的配置设置项目,然后开始构建对您的应用程序真正重要的内容

If you are new to Spring boot and want to get started with it quickly, then this blog post is for you.

In this post, we’ll build a Restful CRUD API for a simple note-taking application. A Note can have a title and some content. We’ll first build the apis to create, retrieve, update and delete a Note, and then test them using postman.

在本文中,我们将为一个简单的笔记应用程序构建一个Restful CRUD API。笔记可以包含标题和一些内容。我们将首先构建用于创建,检索,更新和删除记事的api,然后使用postman对其进行测试

So, Let’s get started!

Creating the Project

Spring Boot provides a web tool called Spring Initializer to bootstrap an application quickly. Just go to http://start.spring.io and follow the steps below to generate a new project.

Spring Boot提供了一个称为Spring Initializer的Web工具,可以快速引导应用程序。只需转到http://start.spring.io并按照以下步骤生成一个新项目

Step 1 : Click Switch to full version on http://start.spring.io page.

Step 2 : Enter the details as follows -

  • Group : com.zetcode
  • Artifact : easy-notes
  • Dependencies : Web, JPA, MySQL, DevTools

在这里插入图片描述

Once all the details are entered, click Generate Project to generate and download your project. Spring Initializer will generate the project with the details you have entered and download a zip file with all the project folders.

输入所有详细信息后,单击“生成项目”以生成并下载您的项目。Spring Initializer将使用您输入的详细信息生成项目,并下载包含所有项目文件夹的zip文件

Next, Unzip the downloaded zip file and import it into your favorite IDE.

接下来,解压缩下载的zip文件并将其导入您喜欢的IDE

Exploring the Directory Structure

探索目录结构

Following is the directory structure of our Note taking application -

以下是应用程序的目录结构

在这里插入图片描述
Let’s understand the details of some of the important files and directories -

让我们了解一些重要文件和目录的详细信息

pom.xml

<?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"><modelVersion>4.0.0</modelVersion><groupId>com.zetcode</groupId><artifactId>easy-notes</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging><name>easy-notes</name><description>Rest API for a Simple Note Taking Application</description><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.1.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.20</version><scope>runtime</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.hibernate.validator</groupId><artifactId>hibernate-validator</artifactId><version>6.0.18.Final</version></dependency></dependencies><build><pluginManagement><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></pluginManagement></build></project>

1. EasyNotesApplication

This is the main entry point of our Spring Boot application.

这是Spring Boot应用程序的主要入口点

package com.zetcode.easynotes;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;@SpringBootApplication
@EnableJpaAuditing
public class EasyNotesApplication {public static void main(String[] args) {SpringApplication.run(EasyNotesApplication.class, args);}
}

It contains a simple annotation called @SpringBootApplication which is a combination of the following more specific spring annotations -

它包含一个名为@SpringBootApplication的简单注解,该注解是以下更具体的spring注解的组合-

  • @Configuration : Any class annotated with @Configuration annotation is bootstrapped by Spring and is also considered as a source of other bean definitions.

    任何用@Configuration注解的类都由Spring引导,也被视为其他bean定义的源

  • @EnableAutoConfiguration : This annotation tells Spring to automatically configure your application based on the dependencies that you have added in the pom.xml file.

    这个注解告诉Spring根据在pom.xml文件中添加的依赖项自动配置您的应用程序

    For example, If spring-data-jpa or spring-jdbc is in the classpath, then it automatically tries to configure a DataSource by reading the database properties from application.properties file.

    例如,如果spring-data-jpa或spring-jdbc在类路径中,则它将通过从application.properties文件读取数据库属性来自动尝试配置DataSource

  • @ComponentScan : It tells Spring to scan and bootstrap other components defined in the current package (com.zetcode.easynotes) and all the sub-packages.

    它告诉Spring扫描并引导当前程序包(com.zetcode.easynotes)和所有子程序包中定义的其它组件

The main() method calls Spring Boot’s SpringApplication.run() method to launch the application.

main()方法调用Spring Boot的SpringApplication.run()方法来启动应用程序

2. resources/

This directory, as the name suggests, is dedicated to all the static resources, templates and property files.

顾名思义,该目录专用于所有静态资源,模板和属性文件

  • resources/static - contains static resources such as css, js and images.

    包含静态资源,例如CSS,JS和图片

  • resources/templates - contains server-side templates which are rendered by Spring.

    包含由Spring呈现的服务器端模板

  • resources/application.properties - This file is very important. It contains application-wide properties. Spring reads the properties defined in this file to configure your application. You can define server’s default port, server’s context path, database URLs etc, in this file.

    这个文件非常重要。它包含应用程序范围的属性。Spring读取此文件中定义的属性以配置您的应用程序。您可以在此文件中定义服务器的默认端口,服务器的上下文路径,数据库URL等

    You can refer this page for common application properties used in Spring Boot.

    您可以参考此页面以了解Spring Boot中使用的常见应用程序属性

3. EasyNotesApplicationTests - Define unit and integration tests here.

在此处定义单元和集成测试

4. pom.xml - contains all the project dependencies

包含所有项目依赖项

Configuring MySQL Database

配置MySQL数据库

As I pointed out earlier, Spring Boot tries to auto-configure a DataSource if spring-data-jpa is in the classpath by reading the database configuration from application.properties file.

正如我之前指出的,如果spring-data-jpa在类路径中,则Spring Boot会通过从application.properties文件中读取数据库配置来尝试自动配置数据源

So, we just have to add the configuration and Spring Boot will take care of the rest.

因此,我们只需要添加配置,Spring Boot将负责其余的工作

Open application.properties file and add the following properties to it.

打开application.properties文件,并向其中添加以下属性

## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://localhost:3306/notes_app?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.datasource.username = root
spring.datasource.password = MyNewPass4!## Hibernate Properties# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update

You will need to create a database named notes_app in MySQL, and change the spring.datasource.username & spring.datasource.password properties as per your MySQL installation.

您需要在MySQL中创建一个名为notes_app的数据库,并根据您的MySQL安装更改spring.datasource.username和spring.datasource.password属性

In the above properties file, the last two properties are for hibernate. Spring Boot uses Hibernate as the default JPA implementation.

在上面的属性文件中,最后两个属性用于hibernate。Spring Boot使用Hibernate作为默认的JPA实现

The property spring.jpa.hibernate.ddl-auto is used for database initialization. I’ve used the value “update” for this property.

spring.jpa.hibernate.ddl-auto属性用于数据库初始化。我已经为此属性使用了“更新”值

It does two things -

  • When you define a domain model, a table will automatically be created in the database and the fields of the domain model will be mapped to the corresponding columns in the table.

    定义域模型时,将在数据库中自动创建一个表,并且该域模型的字段将映射到表中的相应列

  • Any change to the domain model will also trigger an update to the table. For example, If you change the name or type of a field, or add another field to the model, then all these changes will be reflected in the mapped table as well.

    域模型的任何更改也将触发对该表的更新。例如,如果您更改字段的名称或类型,或向模型添加另一个字段,则所有这些更改也将反映在映射表中

Using update for spring.jpa.hibernate.ddl-auto property is fine for development. But, For production, You should keep the value of this property to “validate”, and use a database migration tool like Flyway for managing changes in the database schema.

对spring.jpa.hibernate.ddl-auto属性使用update可以进行开发。但是,对于生产而言,您应将此属性的值保留为“ validate”,并使用Flyway之类的数据库迁移工具来管理数据库架构中的更改

Creating the Note model

创建笔记模型

All right! Let’s now create the Note model. Our Note model has following fields -

现在创建一个Note模型。Note模型具有以下字段

  • id: Primary Key with Auto Increment.

    具有自动增量的主键

  • title: The title of the Note. (NOT NULL field)

    笔记的标题(非空字段)

  • content: Note’s content. (NOT NULL field)

    笔记的内容(非空字段)

  • createdAt: Time at which the Note was created.

    笔记创建的时间

  • updatedAt: Time at which the Note was updated.

    笔记更新的时间

Now, let’s see how we can model this in Spring. Create a new package called model inside com.zetcode.easynotes and add a class named Note.java with following contents -

现在,让我们看看如何在Spring中对此建模。在com.zetcode.easynotes内部创建一个名为model的包,并添加一个名为Note.java的类,其内容如下:

package com.zetcode.easynotes.model;import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.util.Date;@Entity
@Table(name = "notes")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updateAt"}, allowGetters = true)
public class Note {@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id;@NotBlankprivate String title;@NotBlankprivate String content;@Column(nullable = false, updatable = false)@Temporal(TemporalType.TIMESTAMP)@CreatedDateprivate Date createdAt;@Column(nullable = false)@Temporal(TemporalType.TIMESTAMP)@LastModifiedDateprivate Date updateAt;public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getTitle() {return title;}public void setTitle(String title) {this.title = title;}public String getContent() {return content;}public void setContent(String content) {this.content = content;}public Date getCreatedAt() {return createdAt;}public void setCreatedAt(Date createdAt) {this.createdAt = createdAt;}public Date getUpdateAt() {return updateAt;}public void setUpdateAt(Date updateAt) {this.updateAt = updateAt;}
}
  • All your domain models must be annotated with @Entity annotation. It is used to mark the class as a persistent Java class.

    所有域模型都必须使用@Entity注解进行注释。它用于将类标记为持久性Java类

  • @Table annotation is used to provide the details of the table that this entity will be mapped to.

    注解被用于提供此实体映射到的表的详细信息

  • @Id annotation is used to define the primary key.

    注解用于定义主键

  • @GeneratedValue annotation is used to define the primary key generation strategy. In the above case, we have declared the primary key to be an Auto Increment field.

    注解用于定义主键生成策略。在上述情况下,我们已将主键声明为“自动增量”字段

  • @NotBlank annotation is used to validate that the annotated field is not null or empty.

    注解用于验证带注释的字段不为null或为空

  • @Column annotation is used to define the properties of the column that will be mapped to the annotated field. You can define several properties like name, length, nullable, updateable etc.

    注解用于定义将被映射到带注释字段的列的属性。您可以定义几个属性,例如名称,长度,可为空,可更新等

    By default, a field named createdAt is mapped to a column named created_at in the database table. i.e. all camel cases are replaced with underscores.

    默认情况下,名为createdAt的字段映射到数据库表中名为created_at的列。也就是说,所有驼峰案例都用下划线代替

    If you want to map the field to a different column, you can specify it using -

    如果要将字段映射到其他列,则可以使用-

    @Column(name = "created_on")
    private String createdAt;
    
  • @Temporal annotation is used with java.util.Date and java.util.Calendar classes. It converts the date and time values from Java Object to compatible database type and vice versa.

    注解与java.util.Date和java.util.Calendar类一起使用。它将日期和时间值从Java对象转换为兼容的数据库类型,反之亦然

  • @JsonIgnoreProperties annotation is a Jackson annotation. Spring Boot uses Jackson for Serializing and Deserializing Java objects to and from JSON.

    注解是Jackson注解。Spring Boot使用Jackson将Java对象与JSON进行序列化和反序列化

    This annotation is used because we don’t want the clients of the rest api to supply the createdAt and updatedAt values. If they supply these values then we’ll simply ignore them. However, we’ll include these values in the JSON response.

    使用此注解的原因是,我们不希望其余api的客户端提供createdAt和updatedAt值。如果它们提供了这些值,那么我们将忽略它们。但是,我们会将这些值包括在JSON响应中

Enable JPA Auditing

启用JPA审核

In our Note model we have annotated createdAt and updatedAt fields with @CreatedDate and @LastModifiedDate annotations respectively.

在Note模型中,分别用@CreatedDate和@LastModifiedDate注释了createdAt和updatedAt字段

Now, what we want is that these fields should automatically get populated whenever we create or update an entity.

现在,想要的是每当我们创建或更新实体时都应自动填充这些字段

To achieve this, we need to do two things -

为此,我们需要做两件事-

1. Add Spring Data JPA’s AuditingEntityListener to the domain model.

将Spring Data JPA的AuditingEntityListener添加到域模型

We have already done this in our Note model with the annotation @EntityListeners(AuditingEntityListener.class).

我们已经在Note模型中使用@EntityListeners(AuditingEntityListener.class)注解进行了此操作

2. Enable JPA Auditing in the main application.

在主应用程序中启用JPA审核

Open EasyNotesApplication.java and add @EnableJpaAuditing annotation.

打开EasyNotesApplication.java并添加@EnableJpaAuditing注解

package com.zetcode.easynotes;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;@SpringBootApplication
@EnableJpaAuditing
public class EasyNotesApplication {public static void main(String[] args) {SpringApplication.run(EasyNotesApplication.class, args);}
}

Creating NoteRepository to access data from the database

创建NoteRepository以访问数据库中的数据

The next thing we’re gonna do is create a repository to access Note’s data from the database.

我们要做的下一件事是创建一个存储库,以从数据库访问Note的数据

Well, Spring Data JPA has got us covered here. It comes with a JpaRepository interface which defines methods for all the CRUD operations on the entity, and a default implementation of JpaRepository called SimpleJpaRepository.

Spring Data JPA在这里为我们提供了覆盖。它带有JpaRepository接口,该接口定义了实体上所有CRUD操作的方法,以及JpaRepository的默认实现,称为SimpleJpaRepository

Cool! Let’s create the repository now. First, Create a new package called repository inside the base package com.zetcode.easynotes. Then, create an interface called NoteRepository and extend it from JpaRepository -

现在创建存储库。首先,在基本软件包com.example.easynotes内创建一个名为“ repository”的新软件包。然后,创建一个名为NoteRepository的接口,并从JpaRepository扩展它

package com.zetcode.easynotes.repository;import com.zetcode.easynotes.model.Note;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;@Repository
public interface NoteRepository extends JpaRepository<Note, Long> {}

Note that, we have annotated the interface with @Repository annotation. This tells Spring to bootstrap the repository during component scan.

请注意,我们已经使用@Repository注解对接口进行了注释。这告诉Spring在组件扫描期间引导存储库

Great! That is all you have to do in the repository layer. You will now be able to use JpaRepository’s methods like save(), findOne(), findAll(), count(), delete() etc.

这就是您在存储库层中要做的所有事情。现在,您将能够使用JpaRepository方法,例如save(),findOne(),findAll(),count(),delete()等

You don’t need to implement these methods. They are already implemented by Spring Data JPA’s SimpleJpaRepository. This implementation is plugged in by Spring automatically at runtime.

您无需实现这些方法。它们已经由Spring Data JPA的SimpleJpaRepository实现。Spring会在运行时自动插入该实现

Checkout all the methods available from SimpleJpaRepository’s documentation.

检出SimpleJpaRepository文档中可用的所有方法

Spring Data JPA has a bunch of other interesting features like Query methods (dynamically creating queries based on method names), Criteria API, Specifications, QueryDsl etc.

Spring Data JPA还有许多其它有趣的功能,例如查询方法(基于方法名称动态创建查询),标准API,规范,QueryDsl等

I strongly recommend you to checkout the Spring Data JPA’s documentation to learn more.

我强烈建议您查看Spring Data JPA文档以了解更多信息

Creating Custom Business Exception

创建自定义业务异常

We’ll define the Rest APIs for creating, retrieving, updating, and deleting a Note in the next section.

在下一部分中,将定义用于创建,检索,更新和删除的Rest API

The APIs will throw a ResourceNotFoundException whenever a Note with a given id is not found in the database.

每当在数据库中找不到具有给定id的Note时,API都会引发ResourceNotFoundException

Following is the definition of ResourceNotFoundException. (I’ve created a package named exception inside com.example.easynotes to store this exception class) -

以下是ResourceNotFoundException的定义。(我在com.zetcode.easynotes内创建了一个名为exception的程序包来存储此异常类)

package com.zetcode.easynotes.exception;import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends RuntimeException {private String resourceName;private String fieldName;private Object fieldValue;public ResourceNotFoundException(String resourceName, String fieldName, Object fieldValue) {super(String.format("%s not found with %s : '%s'", resourceName, fieldName, fieldValue));this.resourceName = resourceName;this.fieldName = fieldName;this.fieldValue = fieldValue;}public String getResourceName() {return resourceName;}public String getFieldName() {return fieldName;}public Object getFieldValue() {return fieldValue;}
}

Notice the use of @ResponseStatus annotation in the above exception class. This will cause Spring boot to respond with the specified HTTP status code whenever this exception is thrown from your controller.

注意上面的异常类中@ResponseStatus注解的使用。每当从控制器抛出此异常时,这将导致Spring Boot以指定的HTTP状态代码响应

package com.zetcode.easynotes.controller;import com.zetcode.easynotes.exception.ResourceNotFoundException;
import com.zetcode.easynotes.model.Note;
import com.zetcode.easynotes.repository.NoteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;import javax.validation.Valid;
import java.util.List;@RestController
@RequestMapping("api")
public class NoteController {@AutowiredNoteRepository noteRepository;@GetMapping("/notes")public List<Note> getAllNotes() {return noteRepository.findAll();}@PostMapping("/notes")public Note createNote(@Valid @RequestBody Note note) {return noteRepository.save(note);}@GetMapping("/notes/{id}")public Note getNoteById(@PathVariable(value = "id") Long noteId) {return noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));}@PutMapping("/notes/{id}")public Note updateNote(@PathVariable(value = "id") Long noteId, @Valid @RequestBody Note noteDetails) {Note note = noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));note.setTitle(noteDetails.getTitle());note.setContent(noteDetails.getContent());Note updateNote = noteRepository.save(note);return updateNote;}@DeleteMapping("/notes/{id}")public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteId) {Note note = noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));noteRepository.delete(note);return ResponseEntity.ok().build();}
}

@RestController annotation is a combination of Spring’s @Controller and @ResponseBody annotations.

@RestController注解是Spring的@Controller和@ResponseBody注解的组合

The @Controller annotation is used to define a controller and the @ResponseBody annotation is used to indicate that the return value of a method should be used as the response body of the request.

@Controller注解用于定义控制器,而@ResponseBody注解用于指示应将方法的返回值用作请求的响应主体

@RequestMapping("/api") declares that the url for all the apis in this controller will start with /api.

@RequestMapping(“/api”)声明此控制器中所有api的URL将以/api开头

Let’s now look at the implementation of all the apis one by one.

现在,让我们一一看一下所有api的实现

1. Get All Notes (GET /api/notes)

// Get All Notes
@GetMapping("/notes")
public List<Note> getAllNotes() {return noteRepository.findAll();
}

The above method is pretty straightforward. It calls JpaRepository’s findAll() method to retrieve all the notes from the database and returns the entire list.

上面的方法非常简单。它调用JpaRepository的findAll()方法从数据库中检索所有笔记,并返回整个列表

Also, The @GetMapping("/notes") annotation is a short form of @RequestMapping(value="/notes", method=RequestMethod.GET).

另外,@GetMapping(“/notes”)注解是@RequestMapping(value =“/notes”,method = RequestMethod.GET)的缩写

2. Create a new Note (POST /api/notes)

// Create a new Note
@PostMapping("/notes")
public Note createNote(@Valid @RequestBody Note note) {return noteRepository.save(note);
}

The @RequestBody annotation is used to bind the request body with a method parameter.

@RequestBody注解用于将请求主体与方法参数绑定

The @Valid annotation makes sure that the request body is valid. Remember, we had marked Note’s title and content with @NotBlank annotation in the Note model?

@Valid注解确保请求正文有效。还记得我们在Note模型中用@NotBlank批注标记Note的标题和内容吗?

If the request body doesn’t have a title or a content, then spring will return a 400 BadRequest error to the client.

如果请求正文没有标题或内容,那么spring将向客户端返回400 BadRequest错误

3. Get a Single Note (Get /api/notes/{noteId})

// Get a Single Note
@GetMapping("/notes/{id}")
public Note getNoteById(@PathVariable(value = "id") Long noteId) {return noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));
}

The @PathVariable annotation, as the name suggests, is used to bind a path variable with a method parameter.

顾名思义,@PathVariable注解用于将路径变量与方法参数绑定

In the above method, we are throwing a ResourceNotFoundException whenever a Note with the given id is not found.

在上述方法中,每当找不到具有给定id的Note时,都将引发ResourceNotFoundException

This will cause Spring Boot to return a 404 Not Found error to the client (Remember, we had added a @ResponseStatus(value = HttpStatus.NOT_FOUND) annotation to the ResourceNotFoundException class).

这将导致Spring Boot向客户端返回404 Not Found错误(请记住,我们已经在ResourceNotFoundException类中添加了@ResponseStatus(value = HttpStatus.NOT_FOUND)注解)

4. Update a Note (PUT /api/notes/{noteId})

// Update a Note
@PutMapping("/notes/{id}")
public Note updateNote(@PathVariable(value = "id") Long noteId,@Valid @RequestBody Note noteDetails) {Note note = noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));note.setTitle(noteDetails.getTitle());note.setContent(noteDetails.getContent());Note updatedNote = noteRepository.save(note);return updatedNote;
}

5. Delete a Note (DELETE /api/notes/{noteId})

// Delete a Note
@DeleteMapping("/notes/{id}")
public ResponseEntity<?> deleteNote(@PathVariable(value = "id") Long noteId) {Note note = noteRepository.findById(noteId).orElseThrow(() -> new ResourceNotFoundException("Note", "id", noteId));noteRepository.delete(note);return ResponseEntity.ok().build();
}

Running the Application

We’ve successfully built all the apis for our application. Let’s now run the app and test the apis.

我们已经为我们的应用程序成功构建了所有API。现在运行应用程序并测试api

Just go to the root directory of the application and type the following command to run it -

只需转到应用程序的根目录并键入以下命令即可运行它-

$ mvn spring-boot:run

The application will start at Spring Boot’s default tomcat port 8080.

该应用程序将从Spring Boot的默认tomcat端口8080启动

Great! Now, It’s time to test our apis using postman.

现在,该使用postman测试我们的api了

Testing the APIs

Creating a new Note using POST /api/notes API

在这里插入图片描述

Retrieving all Notes using GET /api/notes API

在这里插入图片描述

Retrieving a single Note using GET /api/notes/{noteId} API

在这里插入图片描述

Updating a Note using PUT /api/notes/{noteId} API

在这里插入图片描述

Deleting a Note using DELETE /api/notes/{noteId} API

在这里插入图片描述

More Resources

The application that we built in this article had only one domain model. If you want to learn how to build REST APIs in an application with more than one domain models exhibiting a one-to-many relationship between each other, then I highly recommend you to check out the following article -

在本文中构建的应用程序只有一个域模型。如果想学习如何在一个以上具有相互之间一对多关系的域模型的应用程序中构建REST API,那么我强烈建议您查看以下文章-

Spring Boot, JPA, Hibernate One-To-Many mapping example

Also, Go through the following article to learn how to build a full stack application with authentication and authorization using Spring Boot, Spring Security and React -

另外,阅读以下文章,了解如何使用Spring Boot,Spring Security和React构建具有身份验证和授权的完整全栈应用程序-

Spring Boot + Spring Security + JWT + MySQL + React Full Stack Polling App - Part 1

Conclusion

Congratulations folks! We successfully built a Restful CRUD API using Spring Boot, Mysql, Jpa and Hibernate.

You can find the source code for this tutorial on my github repository. Feel free to clone the repository and build upon it.

https://www.callicoder.com/hibernate-spring-boot-jpa-one-to-many-mapping-example/)

Also, Go through the following article to learn how to build a full stack application with authentication and authorization using Spring Boot, Spring Security and React -

另外,阅读以下文章,了解如何使用Spring Boot,Spring Security和React构建具有身份验证和授权的完整全栈应用程序-

Spring Boot + Spring Security + JWT + MySQL + React Full Stack Polling App - Part 1

Conclusion

Congratulations folks! We successfully built a Restful CRUD API using Spring Boot, Mysql, Jpa and Hibernate.

You can find the source code for this tutorial on my github repository. Feel free to clone the repository and build upon it.

Thank you for reading. Please ask any questions in the comment section below.

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. 防静电塑料包装

    ■ 简介防静电袋可以最大程度地保护静电敏感元器件免受潜在静电危害,它们独特的法拉第电笼构造形成“感应罩”效应,以达到对袋内物品的屏蔽和防静电功效,外层耐磨金属涂层和内层乙烯材料,经复杂工艺处理对静电屏蔽保护做到尽善尽美,半透明热封袋型的工艺,可清楚辨认袋内的…...

    2024/5/1 23:09:27
  2. 快速排序进阶

    三月不练手生。翻出了以前写的快速排序、单链表快排和scala快排。老老实实写把基础版写对就足够。 本文代码均经过测试。 1,快速排序的C++写法: #include <iostream> #include <vector> #include <algorithm>using namespace std;int getPartition(int arr…...

    2024/4/19 19:16:21
  3. 华为 openGauss数据库社区 openGauss数据库源代码

    2020年7月1日,华为正式宣布开源数据库能力,开放openGauss数据库源代码, 并成立openGauss开源社区, 社区官网(http://opengauss.org)同步上线。关于openGaussopenGauss是一款开源关系型数据库管理系统,采用木兰宽松许可证v2发行。openGauss内核源自PostgreSQL,深度融合华为在…...

    2024/4/16 16:42:50
  4. Linux彻底卸载Nginx

    本机环境:centos7使用yum安装的Nginx1.首先输入命令 ps -ef | grep nginx检查一下nginx服务是否在运行。[root@localhost /]# ps -ef |grep nginx root 3163 2643 0 14:08 tty1 00:00:00 man nginx root 5427 1 0 14:50 ? 00:00:00 nginx: m…...

    2024/4/16 16:42:44
  5. STM32CubeMX、STM32库的安装过程 及problem during Unzip of File的解决办法

    一、STM32CubeMX安装过程 链接:https://pan.baidu.com/s/1Wf4AdPBiRAkbOf83qz9UqA 提取码:tbkq二、STM32库安装过程 步骤如下: 方法一、在线安装 (如果遇到网速慢,可以选择方法二) 、方法二、本地安装包安装 安装包下载链接 链接:https://pan.baidu.com/s/14leLLSGs79zh…...

    2024/4/16 16:42:32
  6. 在Eclipse EE上搭建基于Scala文件的Maven项目

    在Eclipse EE上搭建基于Scala文件的Maven项目这篇博客是笔者在进行创新实训课程项目时所做工作的回顾。对于该课程项目所有的工作记录,读者可以参阅下面的链接。 注意!这篇博文不会涉及在机器上安装Hadoop,Spark等环境,仅仅是能够在Eclipse EE上搭建基于Scala文件的Maven项…...

    2024/4/16 16:42:20
  7. 记录一次已解决的异常故障

    记录一次已解决的异常故障描述:centos7.5服务器,使用crontab定时调用kettle执行数据库任务。问题:定时任务完成后,数据库记录出现两条一模一样的记录,时间也一样,导致数据异常故障排除:查找crontab调用日志,查看kettle日志,均只调用一次,数据库存储过程存在两次执行记…...

    2024/4/18 14:07:16
  8. 51单片机8*8点阵显示“中国”

    #include <reg52.h> #include <intrins.h> //位移函数 sbit DIO=P3^4; //2片74HC595数据输入端 sbit S_CLK=P3^5;//串行输入时钟 sbit R_CLK=P3^6;//并行输出时钟 unsigned char code table[2][8]={0xEF,0xEF,0xEF,0x01,0x6D,0x01,0xEF,0xEF,0x01,0x7D,0x01,0x69,0…...

    2024/4/24 14:30:03
  9. jdbcTemplate.queryForObject 没查到抛异常

    当结果集合的size为0或者大于1时,就会抛出异常。 解决方法有两个: (1)通过修改数据库:删除数据库中对应名称(column)相同的记录,留下只剩"1"条。 (2)通过更换方法:使用query方法返回list对象(该方法能返回所有查询记录)...

    2024/4/18 22:39:44
  10. Kotlin - 变量 val 和 var

    什么是变量 变量是一个值的存储空间,这个值可以是一个字符串、一个数字或者其他东西。 每个变量都有一个名称(或标识符)来区别于其他变量。 可以通过变量的名称访问值。变量是程序中最常用的元素之一,因此理解如何使用它们非常重要。 声明变量 在开始使用变量之前,必须先声明…...

    2024/4/20 9:06:01
  11. Java实现文件浏览器下载

    前言:先说下需求,项目需求是用户一点击一个前端页面的链接就可以下载一个压缩包.因为就1个文件,使用文件管理系统像fastDSF,阿里云的OSS这种没必要,直接放在nginx服务器上的怕不好管理,于是给我限定了把文件打包到部署时候的jar包中并实现浏览器下载. 废话不多说,直接上代码! 1…...

    2024/4/20 12:27:16
  12. 查询字符串参数处理小利器快速格式化get请求中的问号拼接的产生-querystring

    一、查询字符串参数处理-插件方式处理querystring.stringify()接收3个参数第一个参数,解析后的 url 对象querystring.stringify({name:dyh,course:[jade,node],from:zh})//运行结果 name=dyh&course=jade&course=node&from=zh第二个参数,query参数之间的链接符号…...

    2024/4/29 1:06:09
  13. 本地项目提交到Github上

    1.在个人github主页创建一个空仓库2.填写完相关资料后再项目文件中打开本地git客户端3.进入到刚刚的新建仓库中,如图操作3.依次在git客户端内输入以下命令,这部会用到上面复制到的地址 git initgit add .origin后面的地址是你刚刚自己复制的地址 git remote add origin https:/…...

    2024/4/25 12:33:31
  14. iOS逆向 | 数字签名与证书

    参考来源 https://ke.qq.com/course/314070 什么是数字签名 数字签名(又称公钥数字签名)是只有信息的发送者才能产生的别人无法伪造的一段数字串,这段数字串同时也是对信息的发送者发送信息真实性的一个有效证明。它是一种类似写在纸上的普通的物理签名,但是使用了公钥加密…...

    2024/4/18 13:42:53
  15. Centos7中iptables防火墙的设置

    防火墙的种类:包过滤防火墙 代理防火墙 状态检测技术通信原理: 一台客户端>iptables>服务器 数据包---》iptables把数据包分类进行处理(各种表rew,mangle,nat,filter表等)-- -》 filter:允许,不允许通过数据包。 nat:进行数据转换的数据包。 mangle:对数据包做…...

    2024/4/20 13:05:37
  16. HTML html+css写一个简易的下拉列表 ul li 动画下拉 放在那就下拉

    1. 在body中写ul列表2.在style中写css样式整个列表的宽高和背景颜色每个li行标签设置宽高 边缘线 文本居中 和 关闭list样式将不是first的li标签隐藏父子选择+后续兄弟选择 将隐藏的显示出来 效果:鼠标放在上面...

    2024/4/16 16:42:56
  17. [算法]最长公共前缀

    题目编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 “”。示例输入: [“flower”,“flow”,“flight”] 输出: “fl”输入: [“dog”,“racecar”,“car”] 输出: “” 解释: 输入不存在公共前缀。这是一道简单题,没什么说的 class Solut…...

    2024/4/26 8:44:01
  18. SpringBoot切换不同的实现时,出现nullPointer问题

    1,有时候算法需要迭代,相同的接口需要多个实现,自己可以随意切换,接口类:package com.xxx.shortvideo.manager;public interface VideoRecommendedManger {FeedVideoByUserDTO getVideoByUser(FeedVideoByUserReq req);}2, 针对接口有两个实现3,通过配置config类来实现pa…...

    2024/4/16 16:42:38
  19. Netty之WebSocket应用

    1. 什么是Netty?Netty是一个高性能事件驱动,异步非阻塞的IO Java开源框架,由Jboss提供,用于建立Tcp等底层的链接,基于Netty可以建立高性能的Http服务器,快速开发高性能、高可靠的网络服务器和客户端程序。它支持Http,websocket,tcp,udp等协议。同时Netty又是基于NIO的…...

    2024/4/16 16:42:09
  20. FFmpeg 报错14 Bad adrress

    ...

    2024/4/16 16:45:11

最新文章

  1. 查找数组中缺失的数字(头歌)

    任务描述 在大小为n的数组中&#xff0c;仅存在大小为[1,n]的数字&#xff0c;数组中的元素有些出现了两次&#xff0c;有些出现了一次&#xff0c;有的数字没有出现。设计一个算法在空间复杂度为O(1)&#xff0c;时间复杂度为O(n)的情况下找到这些没有出现的数字。假设储存结…...

    2024/5/2 1:10:50
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. 云计算概述报告

    以下是一篇论述类文章 文章目录 I. 云计算介绍&#xff08;1&#xff09;云计算基本概念&#xff08;2&#xff09;云计算基本特征 II. 云计算发展历程&#xff08;1&#xff09;云计算的起源&#xff08;2&#xff09;云计算的发展阶段 III. 云计算特点&#xff08;1&#xff…...

    2024/4/30 2:34:28
  4. 在虚拟机ubuntu中端里输入vim filename.不显示vim界面,而是vim可以在以下的 package 找到

    1。打开终端 2.输入以下命令来更新软件包列表&#xff1a; sudo apt update 3&#xff0c;输入以下命令来安装vim编辑器&#xff1a; sudo apt install vim 4等待安装完成后&#xff0c;再次输入"vim filename"命令&#xff0c;应该就能正常显示vim界面了。...

    2024/5/1 19:53:42
  5. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/1 17:30:59
  6. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/4/30 18:14:14
  7. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/4/29 2:29:43
  8. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/4/30 18:21:48
  9. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/4/27 17:58:04
  10. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/4/27 14:22:49
  11. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/4/28 1:28:33
  12. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/4/30 9:43:09
  13. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/4/27 17:59:30
  14. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/4/25 18:39:16
  15. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/4/28 1:34:08
  16. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/4/26 19:03:37
  17. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/4/29 20:46:55
  18. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/4/30 22:21:04
  19. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/1 4:32:01
  20. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/4/27 23:24:42
  21. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/4/28 5:48:52
  22. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/4/30 9:42:22
  23. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/4/30 9:43:22
  24. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/4/30 9:42:49
  25. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  26. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  27. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  28. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  29. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  30. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  31. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  32. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  33. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  34. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  35. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  36. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  37. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  38. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  39. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  40. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  41. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  42. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  43. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  44. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57