Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Apollo to integrate zuul to realize dynamic routing

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge points about how to use Apollo to integrate zuul to achieve dynamic routing. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

1. Preface

The construction of Windows system is based on Ctrip Apollo configuration center distributed mode. On this basis, this paper introduces how to use Apollo to integrate zuul to realize dynamic routing.

2. Project build 2.1 create Spring Boot project apollo-zuul

The apollo-zuul project uses Eureka for service registration and discovery, so here I add the dependency of Eureka Client and the dependency of zuul gateway to implement the routing of micro services.

The pom.xml file adds the following dependencies

Org.springframework.cloud spring-cloud-starter-eureka com.ctrip.framework.apollo apollo-client 0.10.0-SNAPSHOT org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-actuator true org.springframework.cloud spring-cloud-starter-zuul 2.2 download Project

In the official github project, download the project to https://github.com/ctripcorp/apollo and import it into the Eclipse project. The figure below is as follows

As the official distributed building requires a lot of startup parameters, which is too cumbersome, you can consider https://gitee.com/234gdfgsdf/open-capacity-platform/tree/master/apollo-master download

Project organizational structure (function) [port]

├── apollo-Apollo configuration Center

├ ├── apollo-configservice (provides configuration modification, release and other functions for Apollo Portal) [8080]

├ ├── apollo-adminservice (provides configured read, push and other functions for Apollo clients) [8090]

├ ├── apollo-portal (Management Interface) [8070]

├ └── apollo-zuul (Apollo Integrated zuul Gateway)

└── open-eureka-server (Service Registry) [1111]

2.3 application.properties configuration is written to Apollo configuration Center 2.3.1 application.properties

The following configuration information was originally written in the spring boot project, and then written into the configuration center.

Spring.application.name=sop-api-gatewayserver.port=9999zuul.ignored-services= "*" 2.3.2 create an apollo project

I've already created it here, so I won't do too much demonstration.

Upload the information to the configuration file, and then delete the application.properties file in the project.

2.3.3 create a new app.properties file

2.3.4 write code

Application.java startup class

@ RestController@EnableZuulProxy@EnableApolloConfig@EnableDiscoveryClient@SpringBootApplicationpublic class ApiGateWayApp {public static void main (String [] args) {SpringApplication.run (ApiGateWayApp.class, args);}}

Pay attention to the comments.

And then just start it.

3. The results are as follows

You can read the configuration parameters of the Apollo page by visiting http://127.0.0.1:9999/test163, and refresh all Apollo clients after page modification.

These are all the contents of the article "how to use Apollo to integrate zuul for dynamic routing". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report