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)
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.
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;
}
});
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…