πŸš€ Limited-Time Offer! Get 90% OFF on My Udemy Courses Grab the Deal 🎯

Spring Boot CRUD REST APIs Validation Example

πŸŽ“ Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.

▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube

▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube

In this article, we will discuss how to customize the validation for REST API and we will use Hibernate Validator, which is one of the implementations of the bean validation API. We get Hibernate Validator for free when we use Spring Boot Starter Web.
Spring Boot provides a default implementation for handling errors and validations but sometimes we should return a proper error/validation response as per consumer requirement such as
  • A clear message indicating what went wrong? Which field has an error and what are the accepted values? What can the consumer do to fix the error?
  • Proper Response Status Bad Request.
  • Do not include sensitive information in the response.
  • Field validations/Bean validations

Steps to use Validation

1. Hibernate Validator available on the classpath when we use Spring Boot Starter Web.
2. Apply validation annotations to a bean. For example, @NotNull, @Email, @NotBlank, and @Size validations.
3. Enable validation on Spring Rest Controller by adding@Valid annotation in addition to @RequestBody.
4. To customize response validation we need to extend ResponseEntityExceptionHandler class and override handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) method.

Important Note:

Starting with Boot 2.3, we also need to explicitly add the spring-boot-starter-validation dependency:

<dependency> 
 <groupId>org.springframework.boot</groupId> 
 <artifactId>spring-boot-starter-validation</artifactId> 
</dependency>
If you are using Spring boot 2.3 +, make sure that you will use the above dependency to work with Hibernate validator.

In this example, we are using Spring boot 2.0.5 RELEASE so we get Hibernate Validator for free when we use Spring Boot Starter Web.

Table of Contents

  1. What we'll build?
  2. Tools and Technologies Used
  3. Creating and Importing a Project
  4. The pom.xml File
  5. Create JPA Entity and Implementing Validations on the Bean - Employee.java
  6. Create Spring JPA Repository - EmployeeRepository.java
  7. Create Spring Rest Controller and Enable Validation on Controller - EmployeeController.java
  8. Exception(Error) Handling for RESTful Services
  9. Running Application via Application.java
  10. Testing via Postman Client
  11. Source code on GitHub

1. What we'll build?

We will develop a simple Spring Boot RESTful CRUD APIs for the Employee resource and we will implement bean validation using Hibernate Validator.

2. Tools and Technologies Used

  • Spring Boot - 3+
  • JDK - 17 or later
  • Spring Framework - 6+
  • Maven - 3.2+
  • MySQL
  • IDE - Eclipse or Spring Tool Suite (STS)

3. Create a Spring Boot Project

There are many ways to create a Spring Boot application. The simplest way is to use Spring Initializr at http://start.spring.io/, which is an online Spring Boot application generator.
Create project packaging structure as per the below diagram:

4. The pom.xml File

Refer to the below pom.xml for your reference.
 <?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>net.guides.springboot</groupId>
 <artifactId>springboot-crud-rest-api-validation</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>jar</packaging>
 
 <name>springboot-crud-rest-api-validation</name>
 <description>Demo project for Spring Boot</description>
 
 <parent>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-parent</artifactId>
 <version>3.0.4</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>17</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-starter-validation</artifactId>
 </dependency>
 <dependency>
 <groupId>com.h2database</groupId>
 <artifactId>h2</artifactId>
 <scope>runtime</scope>
 </dependency>
 <dependency>
 <groupId>com.mysql</groupId>
 <artifactId>mysql-connector-j</artifactId>
 <scope>runtime</scope>
 </dependency>
 <dependency>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-starter-test</artifactId>
 <scope>test</scope>
 </dependency>
 </dependencies>
 
 <build>
 <plugins>
 <plugin>
 <groupId>org.springframework.boot</groupId>
 <artifactId>spring-boot-maven-plugin</artifactId>
 </plugin>
 </plugins>
 </build>
 </project>
The next step is to create JPA Entity and apply validations on it - Employee.java

5. Create JPA Entity and Implementing Validations on the Bean - Employee.java

Let’s add a few validations to the employee bean. Note that we are using @NotNull, @Email, @NotBlank, and @Size validations.
 package net.guides.springboot.springbootcrudrestapivalidation.model;
 
 import jakarta.persistence.*;
 import jakarta.validation.constraints.Email;
 import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
 
 @Entity
 @Table(name = "employees")
 public class Employee {
 
 private long id;
 
 @NotNull
 @Size(min = 2, message = "First Name should have atleast 2 characters")
 private String firstName;
 
 @NotNull
 @Size(min = 2, message = "Last Name should have atleast 2 characters")
 private String lastName;
 
 @Email
 @NotBlank
 private String emailId;
 
 @NotNull
 @Size(min = 2, message = "Passport should have atleast 2 characters")
 private String passportNumber;
 
 public Employee() {
 
 }
 
 public Employee(String firstName, String lastName, String emailId) {
 this.firstName = firstName;
 this.lastName = lastName;
 this.emailId = emailId;
 }
 
 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 public long getId() {
 return id;
 }
 
 public void setId(long id) {
 this.id = id;
 }
 
 @Column(name = "first_name", nullable = false)
 public String getFirstName() {
 return firstName;
 }
 
 public void setFirstName(String firstName) {
 this.firstName = firstName;
 }
 
 @Column(name = "last_name", nullable = false)
 public String getLastName() {
 return lastName;
 }
 
 public void setLastName(String lastName) {
 this.lastName = lastName;
 }
 
 @Column(name = "email_address", nullable = false)
 public String getEmailId() {
 return emailId;
 }
 
 public void setEmailId(String emailId) {
 this.emailId = emailId;
 }
 
 @Column(name = "passport_number", nullable = false)
 public String getPassportNumber() {
 return passportNumber;
 }
 
 public void setPassportNumber(String passportNumber) {
 this.passportNumber = passportNumber;
 }
 
 }
Next, we will create a Spring Data JPA repository - EmployeeRepository.java

6. Create Spring JPA Repository - EmployeeRepository.java

 package net.guides.springboot.springbootcrudrestapivalidation.repository;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
 import net.guides.springboot.springbootcrudrestapivalidation.model.Employee;
 
 @Repository
 public interface EmployeeRepository extends JpaRepository<Employee, Long>{
 
 }
Let's configure MySQL properties in an application.properties

application.properties

spring.datasource.url = jdbc:mysql://localhost:3306/employees?useSSL=false
spring.datasource.username = root
spring.datasource.password = root
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto = update

7. Create and Enable Validation on Spring Rest Controller - EmployeeController.java

Enabling Validation on the Resource

Add @Valid in addition to @RequestBody.
 @PostMapping("/employees")
 public Employee createEmployee(@Valid @RequestBody Employee employee) {
 return employeeRepository.save(employee);
 }
@Valid annotation enables the hibernate validation.
Let's create a complete EmployeeController class.
 package net.guides.springboot.springbootcrudrestapivalidation.controller;
 
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import jakarta.validation.Valid;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import net.guides.springboot.springbootcrudrestapivalidation.exception.ResourceNotFoundException;
 import net.guides.springboot.springbootcrudrestapivalidation.model.Employee;
 import net.guides.springboot.springbootcrudrestapivalidation.repository.EmployeeRepository;
 
 @RestController
 @RequestMapping("/api/v1")
 public class EmployeeController {
 @Autowired
 private EmployeeRepository employeeRepository;
 
 @GetMapping("/employees")
 public List<Employee> getAllEmployees() {
 return employeeRepository.findAll();
 }
 
 @GetMapping("/employees/{id}")
 public ResponseEntity<Employee> getEmployeeById(@PathVariable(value = "id") Long employeeId)
 throws ResourceNotFoundException {
 Employee employee = employeeRepository.findById(employeeId)
 .orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + employeeId));
 return ResponseEntity.ok().body(employee);
 }
 
 @PostMapping("/employees")
 public Employee createEmployee(@Valid @RequestBody Employee employee) {
 return employeeRepository.save(employee);
 }
 
 @PutMapping("/employees/{id}")
 public ResponseEntity<Employee> updateEmployee(@PathVariable(value = "id") Long employeeId,
 @Valid @RequestBody Employee employeeDetails) throws ResourceNotFoundException {
 Employee employee = employeeRepository.findById(employeeId)
 .orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + employeeId));
 
 employee.setEmailId(employeeDetails.getEmailId());
 employee.setLastName(employeeDetails.getLastName());
 employee.setFirstName(employeeDetails.getFirstName());
 final Employee updatedEmployee = employeeRepository.save(employee);
 return ResponseEntity.ok(updatedEmployee);
 }
 
 @DeleteMapping("/employees/{id}")
 public Map<String, Boolean> deleteEmployee(@PathVariable(value = "id") Long employeeId)
 throws ResourceNotFoundException {
 Employee employee = employeeRepository.findById(employeeId)
 .orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + employeeId));
 
 employeeRepository.delete(employee);
 Map<String, Boolean> response = new HashMap<>();
 response.put("deleted", Boolean.TRUE);
 return response;
 }
 }

8. Exception(Error) Handling for RESTful Services

Spring Boot provides a good default implementation for exception handling for RESTful Services.
Let’s quickly look at the default Exception Handling features provided by Spring Boot.

Resource Not Present

Here is what happens when you fire a request to a resource not found: http://localhost:8080/some-dummy-url
{
 "timestamp": 1512713804164,
 "status": 404,
 "error": "Not Found",
 "message": "No message available",
 "path": "/some-dummy-url"
}
That's a cool error response. It contains all the details that are typically needed.

What happens when we throw an Exception?

Let’s see what Spring Boot does when an exception is thrown from a Resource. we can specify the Response Status for a specific exception along with the definition of the Exception with @ResponseStatus annotation.
Let's create a ResourceNotFoundException.java class.
 package net.guides.springboot.springbootcrudrestapivalidation.exception;
 
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.ResponseStatus;
 
 @ResponseStatus(value = HttpStatus.NOT_FOUND)
 public class ResourceNotFoundException extends Exception{
 
 private static final long serialVersionUID = 1L;
 
 public ResourceNotFoundException(String message){
 super(message);
 }
 }

Customizing Validation Response

Let’s define a simple validation response bean.
package net.guides.springboot.springbootcrudrestapivalidation.exception;
import java.util.Date;
public class ErrorDetails {
 private Date timestamp;
 private String message;
 private String details;
 public ErrorDetails(Date timestamp, String message, String details) {
 super();
 this.timestamp = timestamp;
 this.message = message;
 this.details = details;
 }
 public Date getTimestamp() {
 return timestamp;
 }
 public String getMessage() {
 return message;
 }
 public String getDetails() {
 return details;
 }
}

Create GlobalExceptionHandler class

Let’s now define a @ControllerAdvice to handle validation errors. We do that by overriding the handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) method in the ResponseEntityExceptionHandler.

 @Override
 protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
 HttpHeaders headers, HttpStatus status, WebRequest request) {
 ErrorDetails errorDetails = new ErrorDetails(new Date(), "Validation Failed",
 ex.getBindingResult().toString());
 return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
 } 

Let's put together global exception handling, a resource is not found exception handling and field validations logic in GlobalExceptionHandler.java file.
 package net.guides.springboot.springbootcrudrestapivalidation.exception;
 
 import java.util.Date;
 
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.context.request.WebRequest;
 import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
 
 @ControllerAdvice
 public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
 @ExceptionHandler(ResourceNotFoundException.class)
 public ResponseEntity<?> resourceNotFoundException(ResourceNotFoundException ex, WebRequest request) {
 ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
 return new ResponseEntity<>(errorDetails, HttpStatus.NOT_FOUND);
 }
 
 @ExceptionHandler(Exception.class)
 public ResponseEntity<?> globleExcpetionHandler(Exception ex, WebRequest request) {
 ErrorDetails errorDetails = new ErrorDetails(new Date(), ex.getMessage(), request.getDescription(false));
 return new ResponseEntity<>(errorDetails, HttpStatus.INTERNAL_SERVER_ERROR);
 }
 
 @Override
 protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
 HttpHeaders headers, HttpStatus status, WebRequest request) {
 ErrorDetails errorDetails = new ErrorDetails(new Date(), "Validation Failed",
 ex.getBindingResult().toString());
 return new ResponseEntity(errorDetails, HttpStatus.BAD_REQUEST);
 } 
 }

9. Running Application

This spring boot application has an entry point Java class called SpringbootCrudRestApiValidationApplication.java with the public static void main(String[] args) method, which you can run to start the application.
 package net.guides.springboot.springbootcrudrestapivalidation;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 @SpringBootApplication
 public class SpringbootCrudRestApiValidationApplication {
 
 public static void main(String[] args) {
 SpringApplication.run(SpringbootCrudRestApiValidationApplication.class, args);
 }
 }

10. Testing via Postman Client


Employee firstName field validation


Employee emailId field validation

Employee passportNumber field validation

11. Source code on GitHub

The source code of this article is available on my GitHub Repository on springboot-crud-rest-api-validation

Related Spring Boot and Microservices Tutorials/Guides:

The Hidden Magic of Spring Boot: Secrets Every Developer Should Know What Happens When You Hit a Spring Boot REST API Endpoint (Behind the Scenes) Spring Boot Exception Handling Build CRUD REST API with Spring Boot, Spring Data JPA, Hibernate, and MySQL Spring Boot DELETE REST API: @DeleteMapping Annotation Spring Boot PUT REST API — @PutMapping Annotation Spring Boot POST REST API Spring Boot GET REST API — @GetMapping Annotation Spring Boot REST API with Request Param | Spring Boot Course Spring Boot REST API with Path Variable — @PathVariable Chapter 13: Understanding @SpringBootApplication Annotation | Spring Boot Course Chapter 5: Create Spring Boot Project and Build Hello World REST API | Spring Boot Course 10 Real-World Spring Boot Architecture Tips Every Developer Should Follow Top 10 Spring Boot Tricks Every Java Developer Should Know Debugging Spring Dependency Injection Issues - Very Important Common Code Smells in Spring Applications — How to Fix Them Spring Boot + OpenAI ChatGPT API Integration Tutorial Spring Boot Course -> New Series on Medium ❤️ Spring Boot Microservices with RabbitMQ Example React JS + Spring Boot Microservices Dockerizing a Spring Boot Application How to Change the Default Port in Spring Boot How to Change Context Path in Spring Boot Top 10 Spring Boot REST API Mistakes and How to Avoid Them (2025 Update) Spring Boot REST API Best Practices Spring Boot Security Database Authentication Example Tutorial Spring Boot Security Form-Based Authentication Spring Boot Security In-Memory Authentication What is Spring Boot Really All About? Why Spring Boot over Spring? Top 10 Spring Boot Key Features That You Should Know Spring vs Spring Boot Setting Up the Development Environment for Spring Boot Spring Boot Auto-Configuration: A Quick Guide Spring Boot Starters Quick Guide to Spring Boot Parent Starter Spring Boot Embedded Servers Spring Boot Thymeleaf Hello World Example Chapter 10: Spring Boot DevTools | Spring Boot Course Chapter 13: Spring Boot REST API That Returns JSON | Spring Boot Course Spring Boot REST API That Returns List of Java Objects in JSON Format Top 10 Spring Boot Mistakes and How to Avoid Them Advanced Spring Boot Concepts that Every Java Developer Should Know What Are Microservices in Spring Boot? Integrating React Frontend with Spring Boot ChatGPT API (Step-by-Step Guide) Build a Chatbot Using Spring Boot, React JS, and ChatGPT API Top 10 Mistakes in Spring Boot Microservices and How to Avoid Them (With Examples) Spring Boot Security Best Practices: Protecting Your Application from Attacks πŸ”„ Dependency Injection in Spring (Explained with Coding Examples) ⚙️ How Spring Container Works Behind the Scenes How Spring Container Works Behind the Scenes (Spring Container Secrets Revealed!) Spring @Component vs @Bean vs @Service vs @Repository Explained How Component Scanning Works Behind the Scenes in Spring How Spring Autowiring Works Internally Top 20 Spring Boot Best Practices for Java Developers Build Spring Boot React Full Stack Project — Todo App [2025 Update] Spring vs Spring MVC vs Spring Boot Spring Boot Best Practices: Use DTOs Instead of Entities in API Responses Spring Boot DTO Tutorial (Using Java record) – Complete CRUD REST API Implementation Spring Boot Architecture: Controller, Service, Repository, Database and Architecture Flow Java Stream filter() Method with Real-World Examples Spring Boot Auto Configuration Explained | How It Works Spring Boot Profiles: How to Manage Environment-Based Configurations Create a Custom Spring Boot Starter | Step-by-Step Guide Spring Boot Starter Modules Explained | Auto-Configuration Guide Deploy Spring Boot Applications with Profile-Based Settings | Step-by-Step Guide Spring Boot Performance Tuning: 10 Best Practices for High Performance Spring Boot @ComponentScan Annotation | Customizing Component Scanning Difference Between @RestController and @RequestMapping in Spring Boot Spring Boot @Cacheable Annotation – Improve Performance with Caching Spring Boot Redis Cache — @Cacheable Complete Guide When to Use @Service, @Repository, @Controller, and @Component Annotations in Spring Boot Why, When, and How to Use @Bean Annotation in Spring Boot App Java Spring Boot vs. Go (Golang) for Backend Development in 2025 Is Autowired Annotation Deprecated in Spring Boot? Everything You Need to Know 🚫 Stop Making These Common Mistakes in Spring Boot Projects Top 10 Mind-Blowing Spring Boot Tricks for Beginners Why Choose Spring Boot Over Spring Framework? | Key Differences and Benefits How to Run a Spring Boot Application | 5 Easy Ways for Developers What is AutoConfiguration in Spring Boot? | Explained with Example Customize Default Configuration in Spring Boot | 5 Proven Ways Chapter 12: Understanding SpringApplication.run() Method Internals | Spring Boot Course What is CommandLineRunner in Spring Boot? How to Create Custom Bean Validation in Spring Boot Can You Build a Non-Web Application with Spring Boot? How to Disable Auto-Configuration in Spring Boot (Step-by-Step Guide) Top 25 Spring Boot Interview Questions and Answers for Beginners How to Use Java Records with Spring Boot Spring Boot Constructor Injection Explained with Step-by-Step Example 🚫 Stop Using @Transactional Everywhere: Understand When You Actually Need It 🚫 Stop Writing Fat Controllers: Follow the Controller-Service-Repository Pattern 🚫 Stop Using Field Injection in Spring Boot: Use Constructor Injection 🚫 Stop Sharing Databases Between Microservices: Use Database Per Service Pattern 10 Java Microservices Best Practices Every Developer Should Follow How to Choose the Right Java Microservices Communication Style (Sync vs Async) How to Implement Event-Driven Communication in Java Microservices (Step-by-Step Guide with Kafka) Stop Building Tight-Coupled Microservices: Aim for Loose Coupling Spring Boot Microservices E-Commerce Project: Step-by-Step Guide Spring Boot Microservices with RabbitMQ Example React JS + Spring Boot Microservices The Ultimate Microservices Roadmap for Beginners: Building Modern Scalable Systems What Are Microservices in Spring Boot? Top 5 Message Brokers Every Developer Should Know Top 10 Spring Cloud Microservices Best Practices [Removed Deprecated Features] Best Tools for Microservices Development in 2025 How to Break a Monolithic Application into Microservices (E-Commerce Use Case) Monoliths Aren’t Dead — Microservices Are Just Overused When to Break a Monolith: A Developer’s Checklist πŸ‘‘ Java Is Still the King of Microservices — And Here’s the Proof 5 Microservices Design Patterns You Must Know in 2025 Bulkhead Pattern in Microservices — Improve Resilience and Fault Isolation Strangler Fig Pattern in Microservices — Migrate Monolith to Microservices Event Sourcing Pattern in Microservices (With Real-World Example) Circuit Breaker Pattern in Microservices using Spring Boot 3, WebClient and Resilience4j CQRS Pattern in Microservices Aggregator Design Pattern in Microservices — A Complete Guide Database Per Service Pattern in Microservices API Gateway Pattern in Microservices — A Complete Guide Saga Pattern in Microservices: A Step-by-Step Guide Microservices Are a Mess Without These Java Design Patterns️ Java Microservices Interview Questions and Answers for Freshers Top Microservices Interview Questions and Answers for Experienced Professionals Top 10 Microservices Design Pattern Interview Questions and Answers Top Microservices Tricky Interview Questions You Should Know (With Answers) Microservices Best Practices: Building Scalable and Resilient Systems Why Microservices Are the Future of Software Architecture Microservices with Spring Cloud: Simplify Your Architecture Spring Boot and Microservices Roadmap for Beginners [2025 Update] Best Programming Language for Microservices Project Development in 2025 My 50+ Must-Read Microservices Tutorials, Articles and Guides on the Medium Platform
(追記) (θΏ½θ¨˜γ“γ“γΎγ§)

Comments

  1. Hello, I can't solve the problem with @Valid.

    public Employee createEmployee(@Valid @RequestBody Employee employee)

    "Valid cannot be resolved to a type"

    And when I imported

    import javax.validation.Valid;

    "The import javax.validation cannot be resolved"

    Reply Delete
    Replies
    1. I add this dependecy in my "pom.xml" setting to solve my problem

      org.hibernate
      hibernate-validator
      6.1.0.Final


      https://mvnrepository.com/artifact/org.hibernate/hibernate-validator/6.1.0.Final

      Delete

Post a Comment

Leave Comment

[フレーム]

(追記) (θΏ½θ¨˜γ“γ“γΎγ§)
(追記) (θΏ½θ¨˜γ“γ“γΎγ§)
(追記) (θΏ½θ¨˜γ“γ“γΎγ§)

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

[フレーム]

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare