当前位置: 移动技术网 > IT编程>开发语言>Java > Intellij IDEA配置Jetty的方法示例

Intellij IDEA配置Jetty的方法示例

2019年07月19日  | 移动技术网IT编程  | 我要评论

一、在pom.xml中配置jetty插件:

 <build>
  <plugins>
   <plugin>
    <groupid>org.eclipse.jetty</groupid>
    <artifactid>jetty-maven-plugin</artifactid>
    <version>9.1.0.v20131115</version>
   </plugin>
  </plugins>
 </build>

二、在顶部导航栏,如图点击打开edit configurationns…:


三、点击左上角绿色加号,选择maven,然后进行相关配置。


四、在name中编辑一个自己的名字,在parameters中,working directory选中自己项目,在command line中输入org.mortbay.jetty:maven-jetty-plugin:6.1.22:runps:如果是多模块项目,需要勾选resolve workspace artifacts


五、在runner选项下,在vm options中配置启动端口号:-djetty.port=8081


六、点击apply,ok。完成配置

下面是在一个idea中同时运行两个jetty的配置方法:

在idea中运行一个web项目,我们不必要用tomcat服务器,我们可以直接在pom.xml中配置jetty插件,部署在jetty上即可。

在<project></project>里面配置

第一个:

<build>
<plugins>

<!-- jetty插件, 设定context path与spring profile -->
<plugin>
<groupid>org.mortbay.jetty</groupid>
<artifactid>jetty-maven-plugin</artifactid>
<version>8.1.5.v20120716</version>
<configuration>
<jvmargs>-xx:permsize=512m -xx:maxpermsize=512m
-xx:+cmspermgensweepingenabled
-xx:+cmsclassunloadingenabled</jvmargs>
<!-- <reload>automatic</reload> -->
<!-- <scanintervalseconds>2</scanintervalseconds> -->
<reload>manual</reload>
<webappconfig>
<contextpath>/</contextpath> <!--注释一 此处为项目的上下文路径-->
</webappconfig>
<stopkey>foo</stopkey>
<stopport>9998</stopport>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.selectchannelconnector">
<port>8088</port> <!--注释二 此处配置了访问的端口号-->
<maxidletime>60000</maxidletime>
</connector>
</connectors>

</configuration>
</plugin>
</plugins>
</build>

第二个

<build>
<plugins>

<!-- jetty插件, 设定context path与spring profile -->
<plugin>
<groupid>org.mortbay.jetty</groupid>
<artifactid>jetty-maven-plugin</artifactid>
<version>8.1.5.v20120716</version>
<configuration>
<jvmargs>-xx:permsize=512m -xx:maxpermsize=512m
-xx:+cmspermgensweepingenabled
-xx:+cmsclassunloadingenabled</jvmargs>
<!-- <reload>automatic</reload> -->
<!-- <scanintervalseconds>2</scanintervalseconds> -->
<reload>manual</reload>
<webappconfig>
<contextpath>/</contextpath> <!--注释一 此处为项目的上下文路径-->
</webappconfig>
<stopkey>foo</stopkey>
<stopport>9999</stopport>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.selectchannelconnector">
<port>8080</port> <!--注释二 此处配置了访问的端口号-->
<maxidletime>60000</maxidletime>
</connector>
</connectors>

</configuration>
</plugin>
</plugins>
</build>

唯一的不同点在port端口号的配置上。

然后在idea的右部有一个maven project,里面的plugins、jetty、run exploded,运行即可。

有的标签我也不太懂,但是能运行就是不错的,全懂不现实。

maven的dependency和plugin都是先从本地respository,如果没有再去私服或远程仓库下载。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网