Spring Boot Application using Camunda.
This is a simple example which shows how you can connect Camunda to a postgres database.
If you don't already have a postgres database up and running you do so by installing docker and using the docker-compose.yml
file in the resources
folder.
To start the database simple navegate to the directory
../src/main/resources
and run docker-compose up
That will download a postgres image from docker hub and start it up. Once it's finished you'll have a postgres database with the following settings:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
Connecting the database involves two changes, firstly you have to define the datasource in the application.yaml
file.
spring.datasource:
type: org.postgresql.ds.PGSimpleDataSource
username: postgres
password: postgres
url: jdbc:postgresql://localhost:5432/postgres
Then you should get the driver by adding this dependency to your pom.xml
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
You can also build and run the process application with Spring Boot.
- Build the application using:
mvn clean package
- Run the *.jar file from the
target
directory using:
java -jar target/Camunda-Postgrest-Example.jar
For a faster 1-click (re-)deployment see the alternatives below.
- Build and deploy the process application using:
mvn clean package spring-boot:run
- Run the project as a Java application in your IDE using CamundaApplication as the main class.
Once you deployed the application you can run it using Camunda Tasklist and inspect it using Camunda Cockpit.
Built and tested against Camunda Platform version 7.15.0.