Using Pi4J you could access the GPIO pins directly, example here. You could build Pi4J in a docker container and put the Spring boot app in the same container and allow the container to access the GPIO pins.
That would be the backend implementation. For the the client facing implementation you could create a REST API in the Spring boot app, e.g.:
GET https://your.rpi.com/engine/{name}/
which returns JSON status of engine
e.g.
https://your.rpi.com/engine/airconditioning/
returns:
{
"status": "running"
}
then:
PUT https://your.rpi.com/engine/airconditioning/start
PUT https://your.rpi.com/engine/airconditioning/stop
although the above are not strictly REST. They are RPC.
Or PUT to a control endpoint:
PUT https://your.rpi.com/engine/airconditioning/
with the content:
{
"command": "start|stop"
}
PUT would be a better choice as POST is used in REST to create a new resource. You would be changing the status of an existing resource, i.e. an engine.
The code that implements the endpoints e.g.
https://your.rpi.com/engine/{name}/
would be where the Pi4J integration was implemented.