A JBang Microservice implementation with Spring Boot.
There are no build steps, since the application runs with JBang.
First, install the JBang CLI, see https://www.jbang.dev/download for instructions.
Here are the commands that will install the jbang and JDK 17.
# install jbang
curl -Ls https://sh.jbang.dev | bash -s - app setup
# install jdk 17
jbang jdk install 17Simply run the application with JBang.
cd service
jbang Application.javaThe application is designed to run with a PostgreSQL database. You can run a PostgreSQL database with Docker.
docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgresSend a request to the application, this should return an empty list.
curl -v http://localhost:8080/customersThe starting point for this Spring Boot Web/JPA application is the Application.java java file.
There are three instruction words at the beginning of the file, which are DEPS, FILES, and SOURCES.
The first line //usr/bin/env jbang "$0" "$@" ; exit $? defines the file as a jbang file, and jbang executes the Application.java file in turn.
DEPS defines the dependencies, just like Maven or Gradle dependencies.
FILES defines the files such as properties that are in the project and need to be loaded by jbang
SOURCES defines the java class files that are in the project and need to be loaded by jbang
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.springframework.boot:spring-boot-starter-web:3.1.4
//DEPS org.springframework.boot:spring-boot-starter-data-jpa:3.1.4
//DEPS org.postgresql:postgresql:42.6.0
//FILES application.properties
//SOURCES customer/Customer.java
//SOURCES customer/CustomerController.java
//SOURCES customer/CustomerRepository.java