File tree Expand file tree Collapse file tree 6 files changed +74
-1
lines changed
java/com/alwinsimon/UserManagementJavaSpringBoot Expand file tree Collapse file tree 6 files changed +74
-1
lines changed Original file line number Diff line number Diff line change 27
27
<artifactId >spring-boot-starter-test</artifactId >
28
28
<scope >test</scope >
29
29
</dependency >
30
+
31
+ <dependency >
32
+ <groupId >org.springframework.boot</groupId >
33
+ <artifactId >spring-boot-starter-data-jpa</artifactId >
34
+ </dependency >
35
+
36
+ <dependency >
37
+ <groupId >org.postgresql</groupId >
38
+ <artifactId >postgresql</artifactId >
39
+ <scope >runtime</scope >
40
+ </dependency >
30
41
</dependencies >
31
42
32
43
<build >
Original file line number Diff line number Diff line change
1
+ package com .alwinsimon .UserManagementJavaSpringBoot .Controller ;
2
+
3
+ import org .springframework .web .bind .annotation .*;
4
+ //import com.alwinsimon.UserManagementJavaSpringBoot.Model.User;
5
+
6
+ @ RestController
7
+ @ RequestMapping ("/api/v1/user" )
8
+ @ CrossOrigin ("*" )
9
+ public class UserController {
10
+ @ PostMapping ("/register" )
11
+ public String addUser (@ RequestBody String requestBody ){
12
+ System .out .println ("Received request body: " + requestBody );
13
+ return requestBody ;
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ package com .alwinsimon .UserManagementJavaSpringBoot .Model ;
2
+
3
+ import jakarta .persistence .*;
4
+
5
+ @ Entity
6
+ @ Table (name = "_user" ,uniqueConstraints = {@ UniqueConstraint (columnNames = "email" )})
7
+ public class User {
8
+ @ Id
9
+ @ GeneratedValue (strategy = GenerationType .IDENTITY )
10
+ private Long id ;
11
+ private String firstname ;
12
+ private String lastname ;
13
+ @ Column (unique = true )
14
+ private String email ;
15
+ private String password ;
16
+ }
Original file line number Diff line number Diff line change
1
+ package com .alwinsimon .UserManagementJavaSpringBoot .Repository ;
2
+
3
+ import com .alwinsimon .UserManagementJavaSpringBoot .Model .User ;
4
+ import org .springframework .data .jpa .repository .JpaRepository ;
5
+
6
+ public interface UserRepository extends JpaRepository <User , Long > {
7
+ }
Original file line number Diff line number Diff line change 1
- package com .alwinsimon .SpringBootExp1 ;
1
+ package com .alwinsimon .UserManagementJavaSpringBoot ;
2
2
3
3
import org .springframework .boot .SpringApplication ;
4
4
import org .springframework .boot .autoconfigure .SpringBootApplication ;
Original file line number Diff line number Diff line change
1
+ # ====================== Database Connection Configuration ======================
1
2
3
+ # Set the Hibernate dialect for PostgreSQL
4
+ spring.jpa.properties.hibernate.dialect =org.hibernate.dialect.PostgreSQLDialect
5
+
6
+ # Database connection URL
7
+ spring.datasource.url =jdbc:postgresql://localhost:5432/springbootusermanager
8
+
9
+ # Database username
10
+ spring.datasource.username =alwin
11
+
12
+ # Database password
13
+ spring.datasource.password =123456
14
+
15
+ # Generate DDL (Data Definition Language) scripts during startup
16
+ spring.jpa.generate-ddl =true
17
+
18
+ # Hibernate DDL auto mode: update the schema if necessary
19
+ spring.jpa.hibernate.ddl-auto =update
20
+
21
+ # Show SQL statements in the console
22
+ spring.jpa.show-sql =true
23
+
24
+ # Format SQL statements for better readability in the console
25
+ spring.jpa.properties.hibernate.format_sql =true
You can’t perform that action at this time.
0 commit comments