Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f8ef5df

Browse filesBrowse files
committed
3_01_jpa_data_rest.patch
1 parent 331fe54 commit f8ef5df
Copy full SHA for f8ef5df

File tree

Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-2
lines changed
Open diff view settings
Collapse file

‎pom.xml‎

Copy file name to clipboardExpand all lines: pom.xml
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,17 @@
3232
<groupId>org.springframework.boot</groupId>
3333
<artifactId>spring-boot-starter-validation</artifactId>
3434
</dependency>
35-
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-data-rest</artifactId>
38+
</dependency>
39+
<!--
40+
<dependency>
41+
<groupId>org.springframework.data</groupId>
42+
<artifactId>spring-data-rest-hal-browser</artifactId>
43+
<scope>runtime</scope>
44+
</dependency>
45+
-->
3646
<dependency>
3747
<groupId>com.h2database</groupId>
3848
<artifactId>h2</artifactId>
Collapse file

‎src/main/java/ru/javaops/bootjava/repository/UserRepository.java‎

Copy file name to clipboardExpand all lines: src/main/java/ru/javaops/bootjava/repository/UserRepository.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.data.jpa.repository.JpaRepository;
44
import org.springframework.data.jpa.repository.Query;
5+
import org.springframework.data.rest.core.annotation.RestResource;
56
import org.springframework.transaction.annotation.Transactional;
67
import ru.javaops.bootjava.model.User;
78

@@ -11,8 +12,10 @@
1112
@Transactional(readOnly = true)
1213
public interface UserRepository extends JpaRepository<User, Integer> {
1314

15+
@RestResource(rel = "by-email", path = "by-email")
1416
@Query("SELECT u FROM User u WHERE u.email = LOWER(:email)")
1517
Optional<User> findByEmailIgnoreCase(String email);
1618

19+
@RestResource(rel = "by-lastname", path = "by-lastname")
1720
List<User> findByLastNameContainingIgnoreCase(String lastName);
1821
}
Collapse file

‎src/main/resources/application.yaml‎

Copy file name to clipboardExpand all lines: src/main/resources/application.yaml
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,9 @@ spring:
2626
# tcp: jdbc:h2:tcp://localhost:9092/~/voting
2727
username: sa
2828
password:
29-
h2.console.enabled: true
29+
h2.console.enabled: true
30+
31+
data.rest:
32+
# https://docs.spring.io/spring-data/rest/docs/current/reference/html/#getting-started.basic-settings
33+
basePath: /api
34+
returnBodyOnCreate: true

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.