Comment on page
Creating a New Java App

GX gen
If you haven't already, you'll first need to set up your development environment and ensure you have a Grainite server running (can be running locally in a Docker container).
gx gen config app.yaml
Then, run the below command to generate the project and its files based on the configuration This will include a
pom.xml
file for building with Maven. Optional: If you happen to already have an application which uses Maven or Gradle with a pom.xml
or build.gradle
file or for some other reason choose not to use gx gen all
, further instructions can be found at the end of the page.gx gen all -M
Implement your action handlers, client programs, and any other parts of your app's functionality. You may use the API pages here or the Grainite Javadocs for reference.
Build the application using Maven.
mvn package
Then, load the application onto the Grainite server.
gx load
Run the command below to start a sample load generator which will send events to the application.
java -cp target/food_app-jar-with-dependencies.jar org.sample.food_app.Client
<lib path>
can generally be found at `$HOME/grainite/lib`.- Print all events in the topic:
gx topic dump orders_topic
- Print all grains in the table:
gx table dump orders_table
If you happen to already have an application with a
pom.xml
or build.gradle
file or for some other reason choose not to use gx gen all
(which can generate these for you), please follow the instructions below.Maven
Gradle
In your application's
pom.xml
, add the following dependency and repository:pom.xml
1
<dependencyManagement>
2
...
3
<dependency>
4
<groupId>com.grainite</groupId>
5
<artifactId>libgrainite</artifactId>
6
<version>latest</version>
7
</dependency>
8
</dependencyManagement>
9
10
<repositories>
11
...
12
<repository>
13
<id>gitlab-maven</id>
14
<url>https://gitlab.com/api/v4/projects/41132986/packages/maven</url>
15
</repository>
16
</repositories>
In your application's
build.gradle
, add the following dependency and repository:build.gradle
1
repositories {
2
maven {
3
url "https://gitlab.com/api/v4/projects/41132986/packages/maven"
4
}
5
}
6
7
dependencies {
8
implementation 'com.grainite:libgrainite:latest'
9
}
Last modified 5mo ago