-
Notifications
You must be signed in to change notification settings - Fork 0
/
howto.txt
62 lines (48 loc) · 1.91 KB
/
howto.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Required: VS Code, JDK 1.8, Spring Boot, Spring initializr
// correct "java.home" in vscode settings.json !
SETUP
https://spring.io > projects > spring boot > quick start > spring initializr
Select: > Maven Project > Java > 2.2.2 > Group: com.crm > Artifact: crm
> Dependencies: rest repositories, jpa, h2, lombok
> Generate Project
> npx create-react-app client
crm>src>main>java>com>crm>crm> new Folder: model > new File: Contact.java
// Define first model class
crm>src>main>java>com>crm>crm>model> new File ContactRepository.java
//JPA repository (database sql)
crm>src>main>java>com>crm>crm>model> new File DemoLoader.java
// test model connected to database with this demo
crm>src>main>java>com>crm>crm>model> new File ReactAndSpringDataRestApplication.java
// Finalize API Endpoints for Frontend and Backend
crm>src>main>resources edit File: application.properties
// set URL for the API
START SERVER
now run/debug to start server (chose ReactAndSpringDataRestApplication), then:
postman GET http://localhost:8080/api
// res.body:
{
"_links": {
"contacts": {
"href": "http://localhost:8080/api/contacts"
},
"profile": {
"href": "http://localhost:8080/api/profile"
}
}
}
postman POST:
// Headers: Content-Type: application/json
// Body: raw:
{ firstName: "Jane", "lastName": "Doe", "email": "[email protected]"}
>> Gets safed on the server !
START CLIENT
open terminal in client folder and > npm start
Materializecss
// A modern responsive front-end framework based on Material Design
go to http://materializecss.com > Get started > Copy CDN > Paste into public/index.html
After Frontend is finished:
Add RepositoryRestResource to ContactRepository and create ContactsController
// for CORS !
GIT CLONE:
git clone --recursive https://github.com/hgeissler/Contacts-API-FullStack.git
// --recursive needed, because client is a submodule