Don’t say much, get up and do

Use the SpringCloud sample project that comes with the Soul project source code

Project configuration

Soul Gateway Project

Rely on

Add SpringCloud-related dependencies for Soul to POM files

<! --soul springCloud plugin start--> <dependency> <groupId>org.dromara</groupId> <artifactId>soul-spring-boot-starter-plugin-springcloud</artifactId> <version>${last.version}</version> </dependency> <dependency> <groupId>org.dromara</groupId> <artifactId>soul-spring-boot-starter-plugin-httpclient</artifactId> <version>${last.version}</version> </dependency> <! --soul springCloud plugin end--> <dependency> <groupId>org.springframework.cloud</groupId> < artifactId > spring - cloud - Commons < / artifactId > < version > 2.2.0. RELEASE < / version > < / dependency > < the dependency > <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> < version > 2.2.0. RELEASE < / version > < / dependency >Copy the code

Registry we use Eureka, need to add dependencies

<dependency> <groupId>org.springframework.cloud</groupId> < artifactId > spring - the cloud - starter - netflix - eureka - client < / artifactId > < version > 2.2.0. RELEASE < / version > < / dependency >Copy the code

The configuration file

Gateway configuration file

Eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ # your eureka address instance: -- - IP - address: trueCopy the code

SpringCloud project

Rely on

Jar packages related to soul are added to poM files

<dependency>
      <groupId>org.dromara</groupId>
      <artifactId>soul-spring-boot-starter-client-springcloud</artifactId>
      <version>${last.version}</version>
 </dependency>
Copy the code

The configuration file

soul: springcloud: admin-url: http://localhost:9095 context-path: /springcloud full: true # adminUrl: For the IP + port of your soul-admin project, be sure to prefix http:// # contextPath with the route in the Soul gateway for your MVC project. For example, /order, /product, etc., the gateway will route based on your prefixCopy the code

annotations

Add host soul to controller layer and method@SoulSpringCloudClient

test

Start the zookeeper

Start the eureka

Start the gateway management admin

Start soul Gateway

Modifying Management Configurations

On the Gateway Management page, change the SpringCloud plug-in status to openIn the plug-in list, we can see in the SpringCloud menu that the url path of the project has been registered with the gateway

Request to test

Use Postman for testingAccess successful!