Commit 449c7023 authored by Alexandre Ducarne's avatar Alexandre Ducarne
Browse files

馃摝 Use Lombok Annotations

parent 353afdbc
......@@ -26,6 +26,7 @@ repositories {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
......@@ -4,10 +4,7 @@ import com.RESTAPI.RESTAPI.Entities.User;
import com.RESTAPI.RESTAPI.Repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
@Controller // This means that this class is a Controller
@RequestMapping(path="/user") // This means URL's start with /demo (after Application path)
......@@ -16,7 +13,7 @@ public class UserController {
// Which is auto-generated by Spring, we will use it to handle the data
private UserRepository userRepository;
@GetMapping(path="/add") // Map ONLY GET Requests
@PutMapping(path="/add") // Map ONLY GET Requests
public @ResponseBody
String addNewUser (@RequestParam String name
, @RequestParam String email) {
package com.RESTAPI.RESTAPI.Entities;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity // This tells Hibernate to make a table out of this class
public class User {
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String name;
private String email;
public Integer getId() {
return id;
public void setId(Integer id) { = id;
public String getName() {
return name;
public void setName(String name) { = name;
public String getEmail() {
return email;
public void setEmail(String email) { = email;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment