Alternative usage of restful framework Jersey - interface as a service

Record another way I use the jersey framework in my project. The java part of the project framework adopts spring+jersey+mybatis, and the database adopts mysql. The idea is actually very simple, use the interface as the resource of jersey. Why is there such a requirement? In fact, it is also very simple. I don't want to write Resource separately. The only purpose is to reduce the amount of code of programmers in a reasonable way. Doing more with less code is something I've been thinking about. Don't talk about theory, let's go directly to the code. web.xml configuration:Enter image description

spring配置:

Enter image description

interface接口类:

Enter image description Enter image description

接口实现类:

Enter image description Enter image description

调用的时候 ajax请求 http://localhost:8080/restful/userInfoService/156 进入的就是UserInfoService接口的getUser方法。
而如果其他的service实现类中需要使用UserInfoService接口的话, 跟传统用法一样,

Enter image description

Enter image description

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324414310&siteId=291194637