好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Intellij IDEA配置Jetty的方法示例

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

?

1

2

3

4

5

6

7

8

9

<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>里面配置

第一个:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<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>

第二个

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

<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,如果没有再去私服或远程仓库下载。

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

原文链接:https://blog.csdn.net/u010246789/article/details/51734017

查看更多关于Intellij IDEA配置Jetty的方法示例的详细内容...

  阅读:19次