I'm trying to get started with Betfair's streaming API for Java, but am having trouble building/running their sample application. Here are the steps that I've taken so far...
Clone project:
git clone https://github.com/betfair/stream-api-sample-code.git
In Eclipse, "Import Projects from File System or Archive", and open the
stream-api-sample-code/java
folder
I now see client, console and swagger projects in my Package explorer.
At the bottom of the Eclipse window, I see 2 Errors:
The project cannot be built until its prerequisite client is built. Cleaning and building all projects is recommended
The project cannot be built until its prerequisite swagger is built. Cleaning and building all projects is recommended
I assume this is because I need to create the swagger files as described here:
So I run this command inside the /stream-api-sample-code folder:
java -jar swagger-codegen-cli-2.2.1.jar generate -i ESASwaggerSchema.json -l java -o java/swagger
I now have lots of files inside /stream-api-sample-code/java/swagger. Before running the command I just had a pom.xml
file in there.
I wasn't sure what to do next, but in eclipse I right-clicked on the swagger project, and selected "Update Project". I now see all the new files in eclipse.
But I now get 888 Errors, such as "AuthenticationMessage cannot be resolved to a type".
What should I try next?
First, add this:
<dependencies>
...
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
...
</dependencies>
..to swagger/pom.xml.
This makes the project build-able. (It should be reported&easy fixed.)
------------------------------------------------------------------------
Reactor Summary:
esa-java-client .................................... SUCCESS [ 0.625 s]
swagger ............................................ SUCCESS [ 13.746 s]
client ............................................. SUCCESS [ 9.434 s]
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 24.259 s
Finished at: 2019-01-23T22:48:56+01:00
Final Memory: 26M/90M
------------------------------------------------------------------------
Second:
java -jar swagger-codegen-cli-2.2.1.jar generate -i ESASwaggerSchema.json -l java
..generates you a (completley new/different) maven project, so please do not:
-o java/swagger
but:
-o java/someothernewfolder
...this generated project you can also import into eclipse ...and it has the same "bug" (see First)). So please also add javax.annotation dependency & build (someothernewfolder
).