The project mainly consists of the following modules
- Register with the service center Eurekasever
- Configure the central ConfigServer
- All front-end pages of the Client
- Gateway service gateway-zuul
- Distributed Springcloud Sleuth link tracking Zipkin
- The consumer user
- The provider menu, the order
- aispringcloud-api
1. Registration Service Center
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class,args); }}Copy the code
Pom.xml depends on files
<? xml version="1.0" encoding="UTF-8"? > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
aispringclouddome
com.snowy.southwind
1.0 the SNAPSHOT < version > < / version > < / parent > < modelVersion > 4.0.0 < / modelVersion > < artifactId > eurekaserver < / artifactId >
org.springframework.cloud
< artifactId > spring - the cloud - starter - netflix - eureka - server < / artifactId > < version > 2.0.2. RELEASE < / version > < / dependency >
Copy the code
The configuration file
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka/
Copy the code
Effect of screenshots
Configure the central ConfigServer
Pom.xml depends on files
<? xml version="1.0" encoding="UTF-8"? > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
aispringclouddome
com.snowy.southwind
1.0 the SNAPSHOT < version > < / version > < / parent > < modelVersion > 4.0.0 < / modelVersion > < artifactId > configServer < / artifactId >
org.springframework.cloud
spring-cloud-config-server
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
. < version > 2.0.2 RELEASE < / version > < / dependency > < / dependencies > < project >
Copy the code
The configuration file
server:
port: 8002
spring:
application:
name: configserver
profiles:
active: native
cloud:
config:
server:
native:
search-locations: classpath:/shared
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
instance-id: config-8002
prefer-ip-address: true
Copy the code
Gateway service gateway-zuul
Pom. The XML file
<? xml version="1.0" encoding="UTF-8"? > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>aispringclouddome</artifactId> <groupId>com.snowy.southwind</groupId> 1.0 the SNAPSHOT < version > < / version > < / parent > < modelVersion > 4.0.0 < / modelVersion > < artifactId > allzuul < / artifactId > <dependencies> <! - word allocation center - > < the dependency > < groupId > org. Springframework. Cloud < / groupId > <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-hystrix-dashboard</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId> </dependency> </dependencies> </project>Copy the code
The configuration file
spring:
application:
name: allzuul
profiles:
active: dev
cloud:
config:
uri: http://localhost:8002
fail-fast: true
Copy the code
server:
port: 8060
spring:
application:
name: allzuul
zipkin:
base-url: http://localhost:9009/
sleuth:
sampler:
probability: 1.0
eureka:
instance:
instance-id: allzuul-8060
prefer-ip-address: true
client:
lease-renewal-interval-in-seconds: 5
lease-expiration-duration-in-seconds: 10
service-url:
defaultZone: http://localhost:8761/eureka/ #zuul: # routes: # eureka-ribbon: # routes: # eureka-ribbon: # path: /ribbon/* # serviceId: # reka-ribbon # reka- Feign: # path: / /Takeaway/* # serviceId: allClient # Allclient: path: /** #Zuul host: # timeout socket-timeout-millis:60000
connect-timeout-millis: 10000
Copy the code
Zuul is combined with Hystrix to achieve circuit breaker Enter localhost: 8060 / login. HTML, input the correct account, call jump back 8030 interface, gateway call succeeds
. Distributed Springcloud Sleuth link tracking Zipkin
Pom. The XML file
<? xml version="1.0" encoding="UTF-8"? > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
aispringclouddome
com.snowy.southwind
1.0 the SNAPSHOT < version > < / version > < / parent > < modelVersion > 4.0.0 < / modelVersion > < groupId > com. Example < / groupId > < artifactId > zipkin - server < / artifactId > < properties > < Java version > 1.8 < / Java version >
Greenwich.SR3
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
io.zipkin.java
zipkin-server
< version > 2.11.8 < / version > < / dependency > < the dependency > < groupId >. IO zipkin. Java < / groupId > < artifactId > zipkin autoconfigure - UI < / artifactId > < version > 2.11.8 < / version > < / dependency > < the dependency >
org.springframework.boot
spring-boot-autoconfigure
org.springframework.boot
spring-boot-maven-plugin
Copy the code
The configuration file
server:
port: 9009
spring:
application:
name: zipkin-server
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/ # registry address management: metrics: web: server: auto-time-requests: falseCopy the code
Implementation effect
I will not demonstrate more modules, there is a need to download
Program source code, please click to download download.csdn.net/download/we…
Please pay attention to more needs and learn to move forward together