This example application is designed to show how spring-boot can be used to create a simple web application with a map and points.
This example will give you insights and a starting point for most of the things you will need to do in your group project
Features:
- Spring MVC used with JSP to initialise map
- leaflet javascript library used to render points on the map
- Spring Rest Controller to provide ReST api for data points used by leaflet
- Swagger/OpenAPI used to document the ReST api
- Spring data JPA used to store data in a database
- In memory HSQL database used - but can be replaced with external MYSQL by changing properties file
- docker-compose used to run example in a docker jetty container
- cargo-maven plugin used to deploy example to a remote jetty container with cargo jetty app installed
Very simple spring mvc JSP tutorial / example https://www.java4coding.com/contents/spring/spring-mvc-example
simple spring ReST example / tutorial https://spring.io/guides/tutorials/rest/ Building REST services with Spring
Spring Rest OpenAPI documentation https://www.baeldung.com/spring-rest-openapi-documentation
Docker-jetty-cargo - https://github.com/mthenw/docker-jetty-cargo/ Note my example is simpler and uses existing jetty container
Deploying Web Applications in Jetty https://www.baeldung.com/deploy-to-jetty
You might also want to look at using letsencrypt with docker:
example nginx letsencrypt: https://github.com/wmnnd/nginx-certbot
related tutorial: https://pentacent.medium.com/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71
InteractiveMapSpringBoot
Example Interactive map web app based on Spring Boot and leaflet with JSP
This example is inspired by the example at
https://github.com/imaginalis/spring-boot-leaflet-starter
with the following changes:
- migrated to spring 5
- moved from leaflet to JSP
- data changed to use HSQLDB and not mysql for testing
- added openapi annotations
mvn clean install
mvn spring-boot:run
UI is at http://localhost:8080/
Swagger / OpenAPI Test UI:
http://localhost:8080/swagger-ui/index.html
Swagger / OpenAPI yaml:
http://localhost:8080/api-docs
docker-compose up
(NOTE - this example has been upgraded to use jetty 10 because there appears to be some stability issues with using cargo in the default jetty 9 container)
docker-compose -f docker-compose-deploy.yml build
docker-compose -f docker-compose-deploy.yml up -d
This Docker-compose script builds a jetty image using the referenced Dockerfile before running it. The Dockerfile adds the jetty cargo remote deployer app to thestandard jetty image.
if the cargo app is deployed you will get a command unknown repsonse from http://localhost:8080/cargo-jetty-deployer/
You can then deploy the application to a remote jetty using the cargo configuration in the pom
mvn clean install
mvn cargo:deploy
mvn cargo:undeploy
If you deploy the app it will show up at http://localhost:8080/
The pom has changed to allow cargo to pick up properties from a properties file.
You need to copy deploy.properties.template
to deploy.properties
and change the values to match your site.
The mvn initialize
goal reads the properties file so when deploying use the command
mvn initialize cargo:deploy
mvn initialize cargo:undeploy
or if doing a full build initialize
is called after clean and before install
mvn clean install cargo:deploy