Expose Service Layer directly in spring mvc

2019-08-16 06:24发布

问题:

Last couple of days I've wondering something: I think it's a nice practice to make controller layer as thin as possible. Just the mappings methods and a single line calling injected service. Nothing more. And develop all the logic in the service itself.

But that idea drove me to another place? It would be possible to expose the service layer directly? I mean: "hack" the spring framework in a way that I only have one controller and using some kind of "convention over configuration" philosophy, define the following uri formats:

http://server:port/api/MyServiceClass/MyPublicMethod

All data would be sent by post and developers only will need to focus on delivering @Service 's and be more "productive" ...

Do you think this could be a good idea? Pros/Cons?

Do you know if there is anybody out there doing something like this?

Any help/ideas/suggestions will be grateful

Thanks in advance