在maven中添加pom配置,需要用到servlet-api包在tomcat下面是自带的,但在jetty中是没有的,因此在jetty的配置中要加上这个依赖

<dependency>
	<groupId>org.apache.geronimo.specs</groupId>
	<artifactId>geronimo-servlet_2.4_spec</artifactId>
	<version>1.1.1</version>
	<scope>provided</scope>
</dependency>

然后就是加载jetty

<build>
		<plugins>
			<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>9.4.5.v20170502</version>
				<configuration>
					<scanIntervalSeconds>10</scanIntervalSeconds>
					<httpConnector>
						<port>8080</port>
					</httpConnector>
					<webApp>
						<contextPath>/crmMgr-web</contextPath>
					</webApp>
				</configuration>
			</plugin>
		</plugins> 
	
	</build>

右击项目->Run As->Maven build…->Gloas一栏敲上 jetty:run就可以运行了。
在这里插入图片描述
设置一下各个配置:
在这里插入图片描述
可以设置VM配置信息:-Xms512m -Xmx512m -XX:MaxNewSize=128m -XX:MaxPermSize=128m

运行中会出现jre问题:提示Perhaps you are running on a JRE rather than a JDK?

这是由于JDK没有配置正确引起的,需要配置JDK

位置在–>【Window】–>【Prefrences】–>【Java】–>【Installed JREs】

在这里插入图片描述
右键工程->属性,修改项目的JDK
在这里插入图片描述
右键项目run as或者debugger as的时候设置JDK
在这里插入图片描述

参考:
Jetty配置:https://blog.csdn.net/shelbyandfxj/article/details/79574551
jre问题:https://blog.csdn.net/hjwang1/article/details/50085839
https://blog.csdn.net/lslk9898/article/details/73836745

GitHub 加速计划 / ma / maven
27
0
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:5 个月前 )
69980eea Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.17.0 to 1.17.1. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.17.0...byte-buddy-1.17.1) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- https://issues.apache.org/jira/browse/MNG-8585 10 天前
0d6ed20c 11 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐