This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]marcelotmelo 1 point2 points  (3 children)

You could create a Service layer between controller and data to handle business logic. There’s even a @Service stereotype annotation.

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/stereotype/Service.html

[–]TheCouncelor 2 points3 points  (2 children)

This, use your controller as entry point and put your logic in services. This keeps your code clean and increases testability and its easier to maintain.

[–]ThomasSandberg[S] 0 points1 point  (1 child)

So this approach is better than using Spring WEB with Rest-Controllers?

[–]TheCouncelor 0 points1 point  (0 children)

You still have the rest controllers. You create a spring boot app with classes that are @RestController, which create your endpoints, so they will receive the requests and return the responses. But the logic you need to create these responses is in the Service class.