Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does 'maven jetty:run' work?

what I have learned are:

  • Jetty is a java servlet
  • Maven is a build automation tool used primarily for Java projects
  • the jetty's url in github is https://github.com/eclipse/jetty.project
  • mvn jetty:run is run a web project from pom config
  • mvn jetty:run are supported by maven-jetty-plugin

So, next what should I do next?

And I want to know what happened when I execute the command mvn jetty:run?

What does it send to jetty when it has being used?

like image 847
freeeze king Avatar asked Dec 05 '16 08:12

freeeze king


People also ask

How do I run Mvn jetty?

port on the command line, for example, "mvn -Djetty. port=9999 jetty:run". Alternatively, you can specify as many connectors as you like. You could also instead configure the connectors in a standard [jetty xml config] file and put its location into the <jettyXml> parameter.

How do I run a WAR file on a jetty server?

Deploying by Copying WAR The easiest way to deploy a web application to Jetty server is probably by copying the WAR file into the $JETTY_HOME/webapps directory. Jetty will scan its $JETTY_HOME/webapps directory at startup for web applications to deploy. Our new app will be deployed at /jetty-app context.

How do I run jetty in Intellij?

You could use your Jetty Server in Intellij IDEA using a Run/Debug Configuration : Run > Edit Configurations... > + > Jetty Server > Local. Then you can add artifacts (war exploded) that will be deployed on your jetty and then simply launch it via Debug (doc here).

What is jetty service?

Jetty provides a web server and servlet container, additionally providing support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and are freely available for commercial use and distribution.


1 Answers

The run goal runs on a webapp that does not have to be built into a WAR. Instead, Jetty deploys the webapp from its sources. It looks for the constituent parts of a webapp in the Maven default project locations, although you can override these in the plugin configuration. For example, by default it looks for:

  • resources in ${project.basedir}/src/main/webapp
  • classes in ${project.build.outputDirectory}
  • web.xml in ${project.basedir}/src/main/webapp/WEB-INF/

The plugin automatically ensures the classes are rebuilt and up-to-date before deployment. If you change the source of a class and your IDE automatically compiles it in the background, the plugin picks up the changed class.

You do not need to assemble the webapp into a WAR, saving time during the development cycle. Once invoked, you can configure the plugin to run continuously, scanning for changes in the project and automatically performing a hot redeploy when necessary. Any changes you make are immediately reflected in the running instance of Jetty, letting you quickly jump from coding to testing, rather than going through the cycle of: code, compile, reassemble, redeploy, test.

https://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#jetty-run-goal

like image 171
chaixxiv Avatar answered Oct 27 '22 08:10

chaixxiv