-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eureka.txt
99 lines (62 loc) · 2.34 KB
/
eureka.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
spring cloud framwork
spring cloud starter config
spring cloud netfli eureka server
### appliaiton.properties
spring.appliation.name=eurela-server
server.port=8761
#dont register itself as client
eureka.client.regiser-with-eureka = false
eureka.client.fetch-registry= false
logging.level.com.netflix.eureka=ON
logging.level.com.netflix.discovery = ON
### Starter:
@SpringBootApplication
@EnableEurekaServer
### login:
https://localhost:8761
### Eureka dashboard:
system status
current time -> uptime
general Info -> total memory, enviroment, cpus
DS replicas
*** instane currently registered with Eureka
Spring data rest:
##### Spring Data REST makes it easy to expose microservices.
##### Spring Data REST builds on top of Spring Data repositories and automatically exports those as REST resources.
#### So how does Spring Data Rest work?
* At application startup, Spring Data Rest finds all of the spring data repositories
* Then, Spring Data Rest creates an endpoint that matches the entity name
* Next, Spring Data Rest appends an S to the entity name in the endpoint
* Lastly, Spring Data Rest exposes CRUD (Create, Read, Update, and Delete) operations as RESTful APIs over HTTP
* There is no need to create a controller or service layer!
spring boot starter web
spring boot starter test
spring boot starter jpa
h2 database
spring boot starter rest
Item.java:
@Entity
public class Item{
@Id
@GenereatedValue(strategy = GenerateType.AUTO)
Private Long id;
Private String name
Private Long description;
}
-> Item Repo:
public interface ItemRepository extends CrudReository<Item,Long>
{
}
-> applicaiton.properties:
logging.level.org.springframework:DEBUG
# H2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url= jdbc:h2:mem:items
To Test:
localhost:8080/items
Item Services:
spring data
JPA Item Repository
Spring DATA REST
For a @SpringBootApplication to be discovery-aware, all that's needed is the Spring Discovery Client (i.e., spring-cloud-starter-netflix-eureka-client dependency) in the classpath. The next step is to annotate the main Spring application class with the @EnableEurekaClient annotation. @EnableEurekaClient is optional if the spring-cloud-starter-netflix-eureka-client dependency is on the classpath.