How JPA 2.1 has become the new EJB 2.0 | Java, SQL and jOOQ.
(blog.jooq.org)
kaif 專案的實例,下面是 Spring mvc 的 unit test super class:
@ActiveProfiles(SpringProfile.TEST)
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@SpringApplicationConfiguration(classes = MvcIntegrationTests.WebTestApplication.class)
public abstract class MvcIntegrationTests {
@Profile(SpringProfile.TEST)
@EnableWebMvc
@ComponentScan(basePackages = "io.kaif.web")
@Import(value = { UtilConfiguration.class,
MessageSourceAutoConfiguration.class,
MockTestConfig.class,
WebConfiguration.class,
FreeMarkerAutoConfiguration.class,
AppProperties.class,
SwaggerConfiguration.class })
public static class WebTestApplication {
}
}
內外 class 都夾了四個 annotation,而且你看上面 annotations,命名都是很難理解的: @WebApplicationConfigurate
是 spring mvc test,@SpringApplicationConfiguration
與 @EnableWebMvc
是 spring boot。這些 annotation 寫多了你真的不知道哪個 annotation 是負責什麼,該放在哪 (無法從名字直接推敲..)
kaif 實例二,這是 Open API 的 restful Controller:
@ApiOperation(
value = "[vote] List votes of the user on multiple debates",
notes = "List votes of the user on multiple "
+ "debates. When you paging debates, "
+ "you may want to know what user voted "
+ "for those debates in the page. "
+ "You can send multiple debateIds "
+ "to obtain votes in batch.")
@RequiredScope(VOTE)
@RequestMapping(value = "/debate",
method = RequestMethod.GET)
public List<V1VoteDto> votesOfDebates(
ClientAppUserAccessToken token,
@ApiParam(value = "comma separated debateIds",
allowMultiple = true)
@RequestParam("debate-id") List<String> debateIds) {
}
其實上面只是一個 /debate?debate-id=xxx
這樣的 restful query 而已,不過你看看這個 anontation 的 訊噪比 實在是低的可憐,一個簡單的 method call 被 annotation 淹沒了(上面混了 swagger/spring mvc/客製的 三種 annotation)
我已經避開 JPA/Hibernate 這種怪獸了,但其他地方還是跑不掉啊,我很懷念用 xml 設定 spring 的年代啊。