Maven 集成 jetty

pom.xml

<properties>
    <jetty.version>9.3.0.M1</jetty.version>
    <server.port>80</server.port>
    <server.context>/my_context</server.context>
</properties>
<build>
    <plugins>
        <plugin>
	    <groupId>org.eclipse.jetty</groupId>
	    <artifactId>jetty-maven-plugin</artifactId>
	    <version>${jetty.version}</version>
	    <configuration>
	        <httpConnector>
		<!-- 设置端口 -->
		    <port>${server.port}</port>
		</httpConnector>
		<webAppConfig>
		    <contextPath>${server.context}</contextPath>
		</webAppConfig>
	    </configuration>
	</plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-server</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-webapp</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-util</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-jmx</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-io</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-servlet</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-security</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-http</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty</groupId>
    	<artifactId>jetty-xml</artifactId>
    	<version>${jetty.version}</version>
    </dependency>
    <dependency>
    	<groupId>org.eclipse.jetty.orbit</groupId>
    	<artifactId>javax.servlet</artifactId>
    	<version>3.0.0.v201112011016</version>
    	<scope>provided</scope>
    </dependency>
    <dependency>
    	<groupId>javax.servlet</groupId>
    	<artifactId>servlet-api</artifactId>
    	<version>3.0-alpha-1</version>
    </dependency>
</dependencies>


dependencies中,按需加入

执行命令: mvn jetty:run

启动成功后浏览器访问 : http://localhost/my_context

你可能感兴趣的:(maven,maven,jetty,集成)