Goal
We want to host on Poja a Spring Boot Application that exposes the /hello
endpoint, for which it answers ... world!
.
How-to in 2 steps
Step 1: Create your application
From the Applications page, click on the Create New button, then:
Provide the name of the application
Provide the Github account where Poja will create the Github repository to put your Poja-generated starter template
Provide the package name, say
com.my.company
. The starter template code will be generated in that package.Provide the name and description of the to-create Github repository. The repository name may differ from the application name.
Save. Wait. And voilà! Your application will be deployed automatically.
/ping
Every generated starter template comes with a
/ping
endpoint. To test your deployment, go to the generated deployment URL, then/ping
it… and it willpong
!
Step 2: Code your endpoint
In the generated Poja starter template, controllers are located in com.my.company.endpoint.rest.controller
package com.my.company.endpoint.rest.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@GetMapping("/hello")
public String helloWorld() {
return "... world!";
}
}
Important !
Do not forget to properly format your code before pushing it the prod or preprod branch, otherwise, the deployment will fail
Windows: run.\format.bat
MacOS & Linux: run
./format.sh
To trigger a deployment, just commit and push the code to the preprod branch of the repository. Wait. And voilà!