Run Stubby4j - Option 1
Download the last version of
stubby4j to your computer from http://central.maven.org/maven2/by/stub/stubby4j/6.0.1/stubby4j-6.0.1.jar, then go to the folder where you saved the jar and run the command.
java -jar stubby4j-6.0.1.jar -d path-to-yaml-config/config.yml
Or you can run it from any other place with
java -jar path-to-jar/stubby4j-6.0.1.jar -d path-to-yaml-config/config.yml
Run Stubby4j - Option 2
Another but similar option - instead of downloading temporarily include
stubby4j as a dependency into your project.
<dependency> <groupId>io.github.azagniotov</groupId> <artifactId>stubby4j</artifactId> <version>6.0.1</version> </dependency>
mvn install in the root folder of your project. That will download the jar to your local Maven repository.
After that do the same as you do in the option 1
Example for Windows
java -jar $HOMEPATH/.m2/repository/io/github/azagniotov/stubby4j/6.0.1/stubby4j-6.0.1.jar -d path-to-yaml-config/config.yml
Run Stubby4j - Option 3
Run stubby4j as a Docker container
FROM <any-image-that-includes-java> RUN wget http://central.maven.org/maven2/io/github/azagniotov/stubby4j/6.0.1/stubby4j-6.0.1.jar -O /usr/local/stubby4j.jar EXPOSE 8889 8882 CMD java -jar /usr/local/stubby4j.jar -d no.yaml --location "0.0.0.0" --watch
http://localhost:8882 is the stubs portal,
http://localhost:8889 is the admin portal. They should be exposed externally.
The command for running a docker image
docker run -p 127.0.0.1:8889:8889 127.0.0.1:8882:8882 <your-image>
Configuration YAML file
When Stubby4j starts it requires you to specify the YAML configuration file (
-d /usr/local/config.yml) where you have to describe the stubs that you want to create. Find more about confuguration yaml files here Endpoint configuration HOWTO
I personally prefer to configure
stubby4j via Http. Usually I specify a non-existing file
CMD java -jar /usr/local/stubby4j.jar -d no.yml -l 0.0.0.0
stubby4j complains that it cannot find
no.yml but proceeds with no configuration - that’s exactly what I need.
UPD: BTW, I created the pull request that allows to start
Stubby4j without having to specify yaml configuration.
If you do everything well then you’ll get these available:
- http://localhost:8882 - the stubs portal
- http://localhost:8889 - the admin portal
- http://localhost:8889/status - configured stubs and other useful info