Jetty服务配置,Maven插件的方式使用。版本9.4.4.v20170414

在maven项目中的pom.xml中添加插件如下:

端口号:8090;项目访问路径:/

<build>
     <finalName>base</finalName>
	 <plugins>
		<!-- jetty插件 -->
		<plugin>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-maven-plugin</artifactId>
			<version>9.4.4.v20170414</version>
			<configuration>
				<httpConnector>
					<port>8090</port> <!-- 端口号 -->
				</httpConnector>
				<webApp>
					<contextPath>/</contextPath> <!-- 项目访问前缀 -->
				</webApp>
				<scanIntervalSeconds>10</scanIntervalSeconds>
			</configuration>
		</plugin>
		<!-- 项目版本号、jdk版本 -->
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.1</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
				<encoding>UTF-8</encoding>
			</configuration>
		</plugin>
	</plugins>
</build>

更新一下项目update project

然后,写一个简单的测试Controller

@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index(String msg, Model model) {
	model.addAttribute("msg", msg);
	return "index";
}

index.jsp内容

好的,使用Goals启动项目:

右击项目:

配置Goals:jetty:run

如果需要加端口号(pom中端口号的优先级高):jetty:run -Djetty.port=8090

点击 Run启动项目服务

ok,测试一下

浏览器访问http://localhost:8090/index?msg=jetty

成功了,推荐一个朋友的公众号,有大量的技术文章哦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

进击的rookie

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值