我有一个jaxrs
服务器,我想设置一个资源类。问题是我的类有一个构造函数,我在其中注入另一个对象的另一个依赖项。
final JAXRSServerFactoryBean serverFactory = new JAXRSServerFactoryBean();
serverFactory.setResourceClasses( MessageService.class);
serverFactory.setResourceProvider( MessageService.class,
new SingletonResourceProvider( new MessageService() ) );
serverFactory.setAddress( "http://localhost:8080/service/" );
serverFactory.setProvider( JacksonJsonProvider.class );
serverFactory.create();
我的MessageService
课程:
public class MessageService
{
private final MessageProvider mp;
public MessageService( final MessageProvider messageProvider )
{
this.mp = messageProvider;
}
}
我收到错误:resource class MessageService has no valid constructor
你能帮我解决这个问题吗?