如何部署一个火花Java Web应用程序? [英] How to deploy a spark Java web app?

查看:113
本文介绍了如何部署一个火花Java Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用spark web框架创建了一个webapp,但我不知道如何部署这个webapp。我很抱歉,如果这是非常基本的,但我是新手来激发框架,我找不到任何指导我如何部署spark webapp的文档。:

I used spark web framework to create a webapp, but I don't know how to deploy this webapp. I'm sorry if this is very basic, but I'm new to spark framework and I cannot find any document that guide me how to deploy a spark webapp.:


  • 如何独立部署spark webapp

  • 如何构建spark webapp(用于war文件或此类文件)并使用Web服务器(jetty或Tomcat)进行部署。

推荐答案

首先需要创建一个可以内置到.war文件(在Eclipse中,这将是一个动态Web项目)

You will first need to create a regular Java project that can be built into a .war file (in Eclipse this would be a Dynamic Web Project)

此链接的spark文档描述了需要添加到项目web.xml文件的内容。 http://sparkjava.com/documentation.html#other-webserver

The spark documentation at this link describes what needs to be added to your projects web.xml file. http://sparkjava.com/documentation.html#other-webserver

过滤器文档中列出的参数值需要指向您已定义路线的类。

the param-value listed in the documentation within the filter needs to point to the class where you have defined your routes.

此外,所有代码以前在main()中需要移动到init()。

Additionally, all the code that was previously in main() needs to be moved to init().

@Override
public void init() {
    get(new Route("/test") {
        @Override
        public Object handle(Request request, Response response) {
            return "response goes here;
        }

    });

另外,为了我将它部署到JBoss,我只需要包含spark库而不是Jetty库。一旦完成,您应该能够构建战争并将其部署到您的服务器,就像使用任何其他Java项目一样。

Also, in order for me to deploy it to JBoss, I had to only include the spark libraries and not the Jetty libraries. Once this was done, you should be able to build the war and deploy it to your server the same way you would any other Java project.

这篇关于如何部署一个火花Java Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆