我使用以下代码创建了服务器
@WebServiceProvider
@ServiceMode(value = Service.Mode.PAYLOAD)
public class Server implements Provider<Source> {
public Source invoke(Source request) {
return new StreamSource(new StringReader("<p>Hello There!</p>"));
}
public static void main(String[] args) throws InterruptedException {
String address = "http://127.0.0.1:8080/";
Endpoint endpoint = Endpoint.create(HTTPBinding.HTTP_BINDING, new Server());
endpoint.publish(address);
System.out.println("Service running at " + address);
System.out.println("Type [CTRL]+[C] to quit!");
Thread.sleep(Long.MAX_VALUE);
}
}
如果我将其作为Java应用程序运行,我可以访问服务器。现在我想注册一些REST apis,以便可以公开它们。我怎么能这样做?
我不想创建动态网络项目。我想只保留它一个java项目。请告诉我。