1
저지에서 Google Guice (jax-rs)를 사용하고 있습니다.Google Guice and Jersey - JAXB에서 인터페이스를 처리 할 수 없습니다. 오류
@POST
public void addUser(UserTO user){
}
UserTO가 인터페이스이지만, Guice에서 내가 구현에 바인딩 :
bind(UserTO.class).to(DefaultUserTO.class);
I JAXB - 예외 (JAXB는 인터페이스를 처리 할 수 없습니다) 내가 그것을 호출하면 방법을 던졌습니다 다음 Guice가이 문제를 처리 할 수 있어야한다고 생각했습니다. 하지만 서버 시작시 뭔가가 잘못되었을 수도 있습니다.
Injector injector =
Guice.createInjector(new GuiceServerModule(),
new JerseyServletModule() {
@Override
protected void configureServlets() {
// Route all requests through GuiceContainer
serve("/*").with(GuiceContainer.class);
}
});
// Create the server.
Server server = new Server(12345);
// Create a servlet context and add the jersey servlet.
ServletContextHandler sch = new ServletContextHandler(server, "/");
// Add our Guice listener that includes our bindings
sch.addEventListener(new GuiceServletConfig(injector));
// Then add GuiceFilter and configure the server to
// reroute all requests through this filter.
sch.addFilter(GuiceFilter.class, "/*", null);
// Must add DefaultServlet for embedded Jetty.
// Failing to do this will cause 404 errors.
// This is not needed if web.xml is used instead.
sch.addServlet(DefaultServlet.class, "/");
// Start the server
server.start();
// Wait until server shut down
server.join();
아니면 구현 만 사용해야합니까?