Webdevelopment with Jetty & Maven

I am very unpleasant to do web development with Maven and Jetty using Eclipse, compare with what I did with Visual Studio. Every time I made changes, even minor changes in my view file (for example, .jsp), then I need to reconfigure the entire network โ†’ wait for the berth to reboot everything before I can see the change.

Is there a better way to do this, something like an automatic plugin that would select these modified files and deploy the modified files to a web server?

+7
eclipse maven-2 jetty
source share
2 answers

The way you use Maven, Jetty (and Eclipse) together is unclear, but since the question is marked by Maven, I will talk about the Maven method. With a war project, one easy way to get started and launch webapp is to use the Maven Jetty Plugin . To do this, simply add the following snippet to your POM:

 <project> ... <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.10</version> </plugin> ... </plugins> ... </build> ... </project> 

With this setting, starting mvn jetty:run will launch the berth container with the application deployed. Any change in presentation will recompile the JSP on request. And to configure the berth plugin to also monitor changes to the Java code, you need to add the scanIntervalSeconds parameter:

scanIntervalSeconds Optional. Pause in seconds between webapp sweeps to check for changes and automatically redeploy automatically if detected. By default, this is 0, which disables the hot deployment scan. A number greater than 0 allows it.

Thus, the configuration may look like this:

 <project> ... <build> <plugins> <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.10</version> <configuration> <scanIntervalSeconds>1</scanIntervalSeconds> </configuration> </plugin> ... </plugins> ... </build> ... </project> 

And if you want to connect a remote debugger, check out these instructions .

This is how I always used Jetty with Maven and Eclipse, and I was always happy with this setting. I never used the Jetty adapter for WTP, the previous setup is simply invincible.

+13
source share

They did not use Jetty with Eclipse, but if you use Tomcat (and I'm sure Jetty will work too) with WTP and the m2eclipse plugin, Eclipse will create and publish your web application every time the resource is saved.

  • Create (or use an existing) Maven project with the 'war' package.

  • In the Eclipse Servers view, right-click and configure the server.

  • Right-click on the configured server and select "Add / Remove Projects" and select your project.

  • Click on the green triangle in the server view to start the server.

Now, Eclipse should automatically create and publish your web application every time you make changes. Note: you must have the m2eclipse plugin AND the m2eclipse WTP integration plugin for this.

0
source share

All Articles