Create an application if you don’t already have one

open command promt (cmd) and write following command but make sure that you have already install maven build lifecycle other wise install it first

c:\>    mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp

[INFO] Generating project in Interactive mode
Define value for property 'groupId': : com.example
Define value for property 'artifactId': : demoapp
Packaging type war

Configure maven to download Jetty 


<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.3.0.v20150612</version>
</plugin>


<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
    <contextPath>/abc</contextPath>
</webApp>
<httpConnector>
              <port>8888</port>
        </httpConnector>
</configuration>

mvn jetty:run
mvn jetty:war-run
 ctrl + c


Configure maven to download Tomcat 7

<plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
</plugin>
mvn clean install tomcat7:run

Webapp Runner


Webapp Runner allows you to launch an application in a Tomcat container on any computer that has a JRE installed. No previous steps to install Tomcat are required when using Webapp Runner. It’s just a jar file that can be executed and configured using the java command.

Configure maven to download Webapp Runner        

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.github.jsimone</groupId>
                                <artifactId>webapp-runner</artifactId>
                                <version>8.5.11.3</version>
                                <destFileName>webapp-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

To build your application simply run:

$ mvn package

Run your app using the java command:

java -jar target/dependency/webapp-runner.jar target/*.war
That’s it. Your application should start up on port 8080.

Refrences

http://www.eclipse.org/jetty/

1 comment:

GenTech said...

Thanks for sharing the article, its really useful. Keep updating more with us.
If you are searching for the best accounting software then you are at the right place. We have developed a product Accounting software development which is completely best in it's environment at very affordable rates.

| Designed by Harhiktech