Spring Java Rest Generator
Generating a Rest API
Overview
This generator enables the deployment of your OpenLegacy Hub project as a REST API service within a Java runtime environment. The output is a low-code Spring Boot Java project that accurately reflects the contract of the generated Hub project.
Once deployed and running, you can easily incorporate the latest changes from the Hub project—such as new methods, removed methods, or modifications to input/output fields—by simply stopping and restarting the service. If the deployed project is integrated with an OPZ provider, make sure to replace the existing OPZ file with an updated version before restarting the service.
Supported Build tools
- Gradle (default)
- Maven
Generating from the CLI
- First, generate a service using an OL Hub project and the Spring Java REST generator; see the ol generate command reference topic to learn more about service generation.
> ol generate --project "your_project_name" --generator spring-java-rest
$ ol generate --project "your_project_name" --generator spring-java-rest --build-tool = gradle
The generated service folder is created. The folder is carrying the project name.
Build and Run a generated Project
# Building the API project
gradle build
# Running the API as a Spring Boot project
gradle bootrun
# Building the API project into the .m2 and the target directory
mvn clean install -DskipTests
# Building the API project in the target directory
mvn clean package -DskipTests
# Running the API as a Spring Boot project
mvn clean spring-boot:run
Updated 5 months ago