-
Notifications
You must be signed in to change notification settings - Fork 5
Library6: ThymeLeaf Web Project RestTemplate (data from API Rest)
Albert edited this page Jun 17, 2022
·
11 revisions
Welcome to the cifojava2022-5 wiki!
-
Base project:
- @Entity
book
fromLibrary1
andJPA-H2
: library6server -
POJO
book
fromLibrary5
andTH
: library6client - POM
- ThymeLeaf dependency
- DataBase H2:
Library6server
-
First-time CREATE DDL : First-time CREATE DDL option (after that
UPDATE
) inapplication.properties
-
First-time CREATE DDL : First-time CREATE DDL option (after that
- Application.properties
- @Service, @CrudRepository JPA 2.0
- @Test JUnit Jupiter
- @Entity
-
To work from base-project
- Architectrure Server (Spring Boot)
<API REST>
Client (Spring Boot) - RestTemplate class :** Synchronous client to perform HTTP requests**, exposing a simple, template method API over underlying HTTP client libraries such as:
- the JDK HttpURLConnection,
- Apache HttpComponents,
- ReponseEntity,
- HttpEntity
- and others.
- WebClient to replace RestTemplate : on-blocking, reactive client to perform HTTP requests, exposing a fluent, reactive API over underlying HTTP client libraries such as Reactor Netty.
- Architectrure Server (Spring Boot)
-
Architectrure : both Spring Boot projects, different ports: 8080/8086
-
RestTemplate :
public Iterable<Book> getAllBooks() { ResponseEntity<List<Book>> response = restTemplate.exchange( "http://localhost:8080/api/books", HttpMethod.GET, null, new ParameterizedTypeReference<List<Book>>() { }); List<Book> books = response.getBody(); return books; }
-
version 1.0 : very basic project Server
-
version 1.0 : very basic project Client
-
version 1.1 : create and update at client