Skip to content

Example how to use JPA in a quarkus REST Service and use this in a pure Javascript Web Application with custom elements and a Rest Client in a javafx-application

License

Notifications You must be signed in to change notification settings

caberger/javafx-cdi-jpa

Repository files navigation

Quarkus Application Example

This Jakarta Enterprise Edition example shows how to deploy an application to the Kubernetes Bare Metal LeoCloud by continuous delivery.

It is made up of the following components:

  • a mysql Database
  • a SPA Browser Client Application implemented in Javascript accessing either the quarkus backend or the express server backend.
  • a supersonic fast application server implemented with quarkus, compiled to a native image
  • a nodejs express server accessing the same database as an alternative to Quarkus

The Application is currently deployed on the LeoCloud

When the source code is pushed the docker images are built automatically with github actions.

Database for local development

To start the database for local development open a terminal in the docker subfolder and run the following:

cd ./docker/mysql
docker-compose up --build

To reset the project and clean the database you can run

make clean

Building on the local machine

to build the application on the local machine run the following:

mvn -Dquarkus.profile=dev clean package
java -jar appsrv/target/application-server-0.5.0-runner.jar

MicroProfile OpenAPI

You can explore the SwaggerUI API with using http://localhost:8080/q/swagger-ui/

You can download the openapi specification file with http://localhost:8080/q/openapi and use the openapi code generator to automatically generate REST clients in Java, Typescript, Javascript etc. etc.

appsrv

This is the application server See the appsrv subfolder for how to use REST/JPA/CDI in Quarkus

www

see the www subfolder for the javascript client

JavaFX

See the application subfolder. This application is out of date, contributions welcome!

Cucumber Feature Tests and Code Coverage

see appsrc/src/test/resources for a feature test. To see the coverage report run the following:

cd ./appsrv
mvn clean compile test jacoco:report

Then open appsrv/target/site/jacoco/index.html. As you see only Person has been tested. Contributions are welcome.

Deploy into the Cloud

Before we deploy to a real cloud we test our application on minikube. First of all we install minikube. This is described here. For Installing kubernetes on Docker Desktop read this article. Note: kubernetes on Desktop does not have the standard storage class, you can create it with this yaml

You have to get your credentials from the cloud, adjust your namespace and baseUrl, then you can deploy the application with:

kubectl deploy -f k8s/app.yaml

Continous Integration and Delivery (CI/CD)

On every push the application is compiled and uploaded to the cloud registry. See the "Actions" tab in this github project for details. See also CI/CD und DevOps in my blog.

Deployment

The Demo can be seen at https://student.cloud.htl-leonding.ac.at/c.aberger/

About

Example how to use JPA in a quarkus REST Service and use this in a pure Javascript Web Application with custom elements and a Rest Client in a javafx-application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published