sidebar_position |
---|
20 |
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import CodeBlock from '@theme/CodeBlock'; import CodeSpringwolfGroovy from '!!raw-loader!./snippets/_springwolf_groovy.gradle'; import CodeSpringwolfMaven from '!!raw-loader!./snippets/_springwolf_maven.xml';
The following instructions are for Kafka services - other protocols are almost the same. Check out the example project for complete examples.
Add the following dependencies:
{CodeSpringwolfGroovy} {CodeSpringwolfMaven}Add the following to your application.properties:
springwolf.docket.base-package=io.github.springwolf.example.consumers
springwolf.docket.info.title=${spring.application.name}
springwolf.docket.info.version=1.0.0
springwolf.docket.servers.kafka-server.protocol=kafka
springwolf.docket.servers.kafka-server.host=${kafka.bootstrap.servers:localhost:29092}
Make sure to change the value of springwolf.docket.base-package
to the package containing your listeners, so that Springwolf will automatically pick them up.
Start the application and open the URLs in your browser:
- JSON:
<host>:<port>/springwolf/docs
- YAML:
<host>:<port>/springwolf/docs.yaml
- UI:
<host>:<port>/springwolf/asyncapi-ui.html
If you configured a different context path in your application, make sure to prepend it to Springwolf URLs: <host>:<port>/<context-path>/springwolf/asyncapi-ui.html
- AsyncAPI and Springwolf presentation at Spring I/O 2024
- Read an elaborated tutorial on Baeldung at https://www.baeldung.com/java-spring-doc-asyncapi-springwolf
- Check out the supported protocols and example projects
- Dive deeper on the next pages