Skip to content

Commit 11ddcfe

Browse files
authored
Merge pull request #3 from alwinsimon/v1
V1 - Completed Basic Configuration.
2 parents c78496b + 5c1b73d commit 11ddcfe

File tree

6 files changed

+74
-1
lines changed

6 files changed

+74
-1
lines changed

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
<artifactId>spring-boot-starter-test</artifactId>
2828
<scope>test</scope>
2929
</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>
3041
</dependencies>
3142

3243
<build>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
}

src/main/java/com/alwinsimon/SpringBootExp1/UserManagementJavaSpringBootApplication.java renamed to src/main/java/com/alwinsimon/UserManagementJavaSpringBoot/UserManagementJavaSpringBootApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.alwinsimon.SpringBootExp1;
1+
package com.alwinsimon.UserManagementJavaSpringBoot;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1+
# ====================== Database Connection Configuration ======================
12

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

0 commit comments

Comments
 (0)