From 4a56378e110abcbf99e1578d73794e2a439861cd Mon Sep 17 00:00:00 2001 From: RAJ KUMAR DUTTA Date: Fri, 15 Apr 2022 15:34:29 +0530 Subject: [PATCH 1/2] In the RegistrationRequest class files found a issue when going through your course, Now a days we have to use the default constructor concept. I have added default constructor in the RegistratioRequest class to get rid of this issue [com-fasterxml-jackson-databind-exc-invaliddefinitionexception-cannot-construct-instance-of-xyz-no-creators-like-default-construct-exist-cannot-deserialize-from-object-value-no-delega/] which I have faced yesterday(14-04-2022) --- .../demo/appuser/AppUserRepository.java | 3 +- .../registration/RegistrationRequest.java | 29 +++++++++++++++---- src/main/resources/application.yml | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/demo/appuser/AppUserRepository.java b/src/main/java/com/example/demo/appuser/AppUserRepository.java index d8eaa8f..81e82c9 100644 --- a/src/main/java/com/example/demo/appuser/AppUserRepository.java +++ b/src/main/java/com/example/demo/appuser/AppUserRepository.java @@ -10,8 +10,7 @@ @Repository @Transactional(readOnly = true) -public interface AppUserRepository - extends JpaRepository { +public interface AppUserRepository extends JpaRepository { Optional findByEmail(String email); diff --git a/src/main/java/com/example/demo/registration/RegistrationRequest.java b/src/main/java/com/example/demo/registration/RegistrationRequest.java index 2dd483a..e054462 100644 --- a/src/main/java/com/example/demo/registration/RegistrationRequest.java +++ b/src/main/java/com/example/demo/registration/RegistrationRequest.java @@ -1,17 +1,34 @@ package com.example.demo.registration; -import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @Getter -@AllArgsConstructor @EqualsAndHashCode @ToString public class RegistrationRequest { - private final String firstName; - private final String lastName; - private final String email; - private final String password; + + //We have to remove the final from here to set the values + private String firstName; + private String lastName; + private String email; + private String password; + + + //We have to use this now a days, if not we are going to face the + // [com-fasterxml-jackson-databind-exc-invaliddefinitionexception-cannot-construct-instance-of-xyz-no-creators- + // like-default-construct-exist-cannot-deserialize-from-object-value-no-delega/] + //I faced the error recently. + //I have used the statergy of default constructor. + + public RegistrationRequest() { + } + + public RegistrationRequest(String firstName, String lastName, String email, String password) { + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.password = password; + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index c270e3e..288f3d4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,7 @@ server: spring: datasource: password: - url: jdbc:postgresql://localhost:5432/registration + url: jdbc:postgresql://localhost:5430/registration username: jpa: hibernate: From 37c292d7d69a0ab8c14b4df170dafc96fac947b6 Mon Sep 17 00:00:00 2001 From: RAJ KUMAR DUTTA Date: Fri, 15 Apr 2022 16:18:56 +0530 Subject: [PATCH 2/2] changing the port from 5430 to 5432. As my Postgresql is running on top of 5430 port so I changed earlier now replcaing the previous port.I have used application.yml file in the project root --- .../com/example/demo/registration/RegistrationRequest.java | 6 ++++-- src/main/resources/application.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/example/demo/registration/RegistrationRequest.java b/src/main/java/com/example/demo/registration/RegistrationRequest.java index e054462..6d02145 100644 --- a/src/main/java/com/example/demo/registration/RegistrationRequest.java +++ b/src/main/java/com/example/demo/registration/RegistrationRequest.java @@ -16,12 +16,14 @@ public class RegistrationRequest { private String password; - //We have to use this now a days, if not we are going to face the + //We have to use this nowadays, if not we are going to face the // [com-fasterxml-jackson-databind-exc-invaliddefinitionexception-cannot-construct-instance-of-xyz-no-creators- // like-default-construct-exist-cannot-deserialize-from-object-value-no-delega/] //I faced the error recently. - //I have used the statergy of default constructor. + //I have used the strategy of default constructor. + + //default constructor public RegistrationRequest() { } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 288f3d4..c270e3e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,7 @@ server: spring: datasource: password: - url: jdbc:postgresql://localhost:5430/registration + url: jdbc:postgresql://localhost:5432/registration username: jpa: hibernate: