marți, 2 ianuarie 2018

Java: Jetty - Using Jetty Maven Plugin

## Install Apache Maven
## No need for jetty -- the plugin will manage all the stuff

#Create war

C:\test\jettyapp> mvn archetype:generate -DgroupId=com.george.test -DartifactId=jetty-plugin-app  -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
C:\test\jettyapp> cd jetty-plugin-app

##Add Jetty Maven plugin - edit pom.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.george.test</groupId>
  <artifactId>jetty-plugin-app</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>jetty-plugin-app Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>jetty-plugin-app</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.11.v20160721</version>
</plugin>
</plugins>
  </build>
</project>

## Deploy the app
C:\test\jettyapp\jetty-plugin-app>mvn jetty:run

## Navigate to http://localhost:8080/


Change context path & port


## Edit pom.xml

<build>
    <finalName>jetty-plugin-app</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.11.v20160721</version>
<configuration>
<webApp>
<contextPath>/testapp</contextPath>
</webApp>
<httpConnector>
<port>8866</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
  </build>



Niciun comentariu:

Trimiteți un comentariu