मैं दोनों HTTPServer और REST हैंडलर चलाने की कोशिश कर रहा हूं। एक समय में केवल एक ही काम एक ही समय में दोनों को काम करने में सक्षम नहीं है। मुझे एचटीएमएल पेज और एपीआई की सेवा करने की ज़रूरत है।HTTP हैंडलर और रीस्टेसी परिनियोजन उपक्रम और विश्राम के साथ
यहां मेरा कोड है।
public class HttpServer {
private final UndertowJaxrsServer server = new UndertowJaxrsServer();
private static String rootPath = System.getProperty("user.dir");
private final Undertow.Builder serverBuilder;
public HttpServer(Integer port, String host) {
serverBuilder = Undertow
.builder()
.addHttpListener(port, host)
.setHandler(
Handlers.path().addPrefixPath(
"/",
Handlers.resource(
new FileResourceManager(new File(
rootPath + "/web"), 100))
.addWelcomeFiles(
rootPath + "/web/index.html")));
server.start(serverBuilder);
}
public DeploymentInfo deployApplication(String appPath,
Class<? extends Application> applicationClass) {
ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplicationClass(applicationClass.getName());
return server.undertowDeployment(deployment, appPath);
}
public void deploy(DeploymentInfo deploymentInfo) throws ServletException {
server.deploy(deploymentInfo);
}
public static void main(String[] args) throws ServletException {
HttpServer myServer = new HttpServer(8080, "0.0.0.0");
DeploymentInfo di = myServer
.deployApplication("/rest", MyApplication.class)
.setClassLoader(HttpServer.class.getClassLoader())
.setContextPath("/my").setDeploymentName("My Application");
myServer.deploy(di);
}
}
पर मैं एक ही सामना करना पड़ रहा पर उपलब्ध होगा कर सकते हैं मुद्दा। क्या आपने एक कामकाज निकाला है? – yyff