Skip to content

Commit 65111a4

Browse files
andrewtobilkomaibin
authored andcommitted
spring-rest-shell (eugenp#2928)
* code snippets for the `Java 9 Stream API improvements` article * code snippets for the `Java 9 Stream API improvements` article [2 attempt] * removed the first attempt * the Spring 5 WebClient * delted stream features test * HttpMediaTypeNotAcceptableExceptionExampleController [0] * reactive web client service was removed * new WebClient * new WebClient [2] * spring-rest-shell init * pom added * readme added
1 parent f9ee21c commit 65111a4

6 files changed

Lines changed: 138 additions & 1 deletion

File tree

spring-5/src/main/java/com/baeldung/web/reactive/client/WebClientController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public void demonstrateWebClient() {
4343
WebClient.RequestHeadersSpec<?> requestSpec2 = uri2.body(BodyInserters.fromObject("data"));
4444

4545
// inserters
46-
BodyInserter<Publisher<String>, ReactiveHttpOutputMessage> inserter1 = BodyInserters.fromPublisher(Subscriber::onComplete, String.class);
46+
BodyInserter<Publisher<String>, ReactiveHttpOutputMessage> inserter1 = BodyInserters
47+
.fromPublisher(Subscriber::onComplete, String.class);
4748

4849
LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>();
4950
map.add("key1", "value1");

spring-rest-shell/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Spring REST Shell Project
2+
3+
### Relevant Articles
4+
5+
- [Spring REST Shell](http://www.baeldung.com/<ARTICLE_URI>)

spring-rest-shell/pom.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.baeldung</groupId>
7+
<artifactId>spring-rest-shell</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-rest-shell</name>
12+
<description>A simple project to demonstrate Spring REST Shell features.</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.5.8.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
</properties>
26+
27+
<dependencies>
28+
<!-- Spring dependencies -->
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-web</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-data-jpa</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-data-rest</artifactId>
40+
</dependency>
41+
42+
<!-- H2 dependency -->
43+
<dependency>
44+
<groupId>com.h2database</groupId>
45+
<artifactId>h2</artifactId>
46+
<scope>runtime</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.springframework.boot</groupId>
54+
<artifactId>spring-boot-maven-plugin</artifactId>
55+
</plugin>
56+
</plugins>
57+
</build>
58+
59+
60+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.baeldung;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class Application {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(Application.class, args);
11+
}
12+
13+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.baeldung.acticle;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
7+
@Entity
8+
public final class Article {
9+
10+
@Id
11+
@GeneratedValue
12+
private Long id;
13+
private String title;
14+
private String content;
15+
16+
public Long getId() {
17+
return id;
18+
}
19+
20+
public void setId(Long id) {
21+
this.id = id;
22+
}
23+
24+
public String getTitle() {
25+
return title;
26+
}
27+
28+
public void setTitle(String title) {
29+
this.title = title;
30+
}
31+
32+
public String getContent() {
33+
return content;
34+
}
35+
36+
public void setContent(String content) {
37+
this.content = content;
38+
}
39+
40+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.baeldung.acticle;
2+
3+
import org.springframework.data.repository.CrudRepository;
4+
import org.springframework.data.repository.query.Param;
5+
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
6+
7+
import java.util.Optional;
8+
9+
@RepositoryRestResource(
10+
path = "articles",
11+
collectionResourceRel = "articles",
12+
itemResourceRel = "article"
13+
)
14+
public interface ArticleRepository extends CrudRepository<Article, Long> {
15+
16+
Optional<Article> findByTitle(@Param("title") String title);
17+
18+
}

0 commit comments

Comments
 (0)