Apache ShenYu Start Demo
#
Environmental preparation- Install JDK1.8+ locally
- Install Git locally
- Install Maven locally
- Choose a development tool, such as IDEA
#
Pull ShenYu codeUse Git to clone code
git clone https://github.com/apache/shenyu.git
#
Compile codeCompile with Maven
cd shenyumvn clean install -Dmaven.javadoc.skip=true -B -Drat.skip=true -Djacoco.skip=true -DskipITs -DskipTests
#
Start the gateway serviceUse development tools, take IDEA as an example.
Start shenyu-admin
(use H2 database by default)
Start shenyu-bootstrap
At this point, shenyu gateway has been activated.
We can open the browser and access the admin console: http://localhost:9095/
#
Start application serviceApache ShenYu provides examples for Http, Dubbo, SpringCloud and other applications to access the shenyu gateway, located in the shenyu-example
module. Here we take the Http service as an example.
If shenyu-example
is not marked as a Maven project by IDEA, you can right-click the pom.xml
file in the shenyu-example
directory to add it as a Maven project.
Start shenyu-examples-http
。
At this time, shenyu-examples-http
will automatically register the interface method annotated with @ShenyuSpringMvcClient
and the related configuration in application.yml to the gateway. When we open the admin console, you can see the relevant configuration in divide and context-path.
#
Test Http requestNow use postman
to simulate http
to request your http
service:
#
Use more pluginsWe can refer to Official Document to use other plugins.
Here is an example of using the param-mapping plugin.
Edit the param-mapping plugin in BasicConfig -> Plugin
and set status
.
Configure selectors and rules in PluginList -> http process
.
Then use postman
to make an http request to /http/test/payment
.