Pull the code and modify the configuration

First visit github.com/dromara/sou… Star and watch the repository as a gateway for use by novices. I need to keep an eye on soul’s development and put it to better use in my work. Then fork the repository to github. Facilitate their own subsequent code learning and annotation. Clone the repository of the fork

git clone [email protected]:zhendiao/soul.git
Copy the code

Then import your own code into IDEA, first looking at the directory structure of the Soul projectIt is obvious that soul-admin is the gateway’s administrative console project. If you open the configuration file, you can provide the built-in H2 database as the data source, but for ease of use, we will use MySQL as the data source. The recommended MySQL version is mysql5. You do not need to manually create a database to modify the mysql configuration. The database is automatically created after the mysql startup.

You can see the screen after startup

Gateway core layer soul-bootstrap

Soul-bootrap serves as the core layer for intercepting external requests. The default data synchronization mode is WebSocket

soul :
    file:
      enabled: true
    corss:
      enabled: true
    dubbo :
      parameter: multi
    sync:
        websocket :
             urls: ws://localhost:9095/websocket
Copy the code

The annotated code also includes other synchronization methods such as Zookeeper, NACOS, HTTP, etc. Over the next few days, several other approaches will be tried

Test project

For the simplest proxy environment setup, see the official website for springboot (HTTP). Create a Springboot project and configure it as follows

Soul: # soul Configuration item for SpringMVC, corresponding to SoulHttpConfig configuration class HTTP: admin-url: http://127.0.0.1:9095 # Soul Admin address context-path: /soulboot # Set the route prefix in the Soul gateway, such as /order, /product, etc. App-name: soulboot # This is the name of the application. Port: 7070 # Your project's startup port is full: False # set true to agent your entire service, false to agent some of your controller server: port: 7070Copy the code

Create a new test Controller

package org.dromara.soul.boot.controller; import org.dromara.soul.client.springmvc.annotation.SoulSpringMvcClient; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/user") public class HomeController { @GetMapping("/get") @SoulSpringMvcClient(path = "/user/get", desc = "get user details ") public String getUser(@requestParam ("id") Integer id) {return "DEMO:" + id; }}Copy the code

You can access the soul-Boostrap port with the routing address of this project

The current question

  • How does soul-bootstrap synchronize data with the admin port

Welcome to search and pay attention to the micro channel surface by small program [Big factory interview assistant] and public number [micro view technology] jointly developed by myself and my friends.