Springcloud's zuul combined with configserver

With the configuration center, the contents of the application.properties file in the microservice project can be extracted to the configuration center (except for the connection configuration center properties)

1. Add a property file to the configuration center, zuul-gateway-[test|dev].properties

   

# web
zuul.routes.api-web.path=/web/**
zuul.routes.api-web.serviceId=front-service
# mobile
#zuul.routes.api-mobile.path=/mobile/**
#zuul.routes.api-mobile.serviceId=mobile-service

 

2.zuul depends on the following

 

<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-zuul</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

 3. Add the file bootstrap.properties in zuul and delete application.properties

 

   

#Corresponding to the property file prefix of the configuration center
spring.application.name=zuul-gateway
server.port=5555
eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server
spring.cloud.config.profile=dev

 

 

1

1

1

1

1

1

1

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326438478&siteId=291194637