The best way to deploy a mooring application - too many options?

I need to deploy a production version of a web application. So far I have tested it with mvn jetty:run . I used to use the actual settings of the pier, but they seem to you only necessary when you want to serve several wars on the same web server. In some ways, this is the most persistent ( mvn package and copy it).

My other purpose is to create a runnable jar ( mvn assembly:single ) that will start the server, but I need to configure it so that the static content src/main/webapp loaded and web.xml can be found.

I also read about the "running war." This can avoid the src/main/webapp problem, as these files are already located in the warfile. However, I do not know how to do this.

I could also stick with mvn jetty:run , but this does not seem to be the best option, because then the production deployment is tied to code, and not to a separate bank.

Any opinions on the best ways or the pros and cons of these different approaches? Am I missing some options?

+4
source share
2 answers

jetty-console-maven-plugin is simple to use and works just fine. When you run the mvn package , you get two wars - one executable. java -jar mywar.war --help gives usage, which allows a bit of configuration (port, etc.).

+2
source

I am not familiar with maven, but this way we get closer to deployment using the built-in Jetty:

We are creating a one-factor JAR with an embed application application and packed with the necessary lib libraries.

We deploy static content in a WAR file (which you can also package in a JAR). Everything is created using the ANT file, which:

1) Create static WAR files (this also creates web.xml) 2) Copy the WAR to application resources 3) Compile the executable JAR

In order for the built-in Jetty to โ€œfind and serveโ€ your static files, add war using WebAppContext for Jetty handlers:

 Server jetty = new Server(port); HandlerList handlers = new HandlerList(); WebAppContext staticContentAsWar = new WebAppContext(); staticContentAsWar.setContextPath("/static/"); staticContentAsWar.setWar(resource_Path_to_WAR); handlers.addHandler(set); jetty.setHandlers(handlers); jetty.start(); 

NTN

+1
source

All Articles