Added code for "Intro to Spring Data REST" artice
This commit is contained in:
committed by
David Morley
parent
574c9f6b49
commit
ce68b89c7b
@@ -0,0 +1,11 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SpringDataRestApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringDataRestApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RepositoryRestResource(collectionResourceRel = "users", path = "users")
|
||||
public interface UserRepository extends PagingAndSortingRepository<WebsiteUser, Long> {
|
||||
List<WebsiteUser> findByName(@Param("name") String name);
|
||||
}
|
||||
41
spring-data-rest/src/main/java/com/baeldung/WebsiteUser.java
Normal file
41
spring-data-rest/src/main/java/com/baeldung/WebsiteUser.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.baeldung;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class WebsiteUser {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
private String name;
|
||||
private String email;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user