Some difficulties to execute and develop quickly a webapp consists in configuring a Java  web app server ?
One of the simplest solution is to use the jetty server with the maven plugin into Eclipse.

Here is the way how to configure all those components to make them rules 🙂

The POM

First, in your maven project, start adding the following lines:

  <dependencies>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>9.1.3.v20140225</version>
      <type>jar</type>
      <scope>runtime</scope>
    </dependency>
  ...
  </dependencies>
  <build>
    ...        
    <plugins>
      <plugin>
       <groupId>org.eclipse.jetty</groupId>
       <artifactId>jetty-maven-plugin</artifactId>
       <version>9.1.3.v20140225</version>
         <configuration>
           <scanIntervalSeconds>10</scanIntervalSeconds>
           <jettyConfig>${jetty.configs}</jettyConfig>
           <reload>manual</reload>
           <contextPath>/</contextPath>
           <webAppConfig>
             <parentLoaderPriority>true</parentLoaderPriority>
           </webAppConfig>
         </configuration>
       </plugin>
     </plugins>
  </build>

For more information about ${jetty.configs}, see the jetty wxiki section about jetty.xml configuration file.

The Jetty

Then, you have to start your project  through the Eclipse maven plugin (m2clipse):

Just add a new Run  configuration with the following maven configurations:

Image

and add these VM parameters

3image

Just copy/paste the following line:

-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000

So, the last steps are:*
– start this run  configuration,
– create a new Debug configuration :

0image

The Run

So, now, in the debug toolbar, just select your debug solution :
2image

And start debugging in the Debug perspective :

1image

That’s it !

McG.

Publicités