对对对~

maven-pom配置 maven-jetty插件出现端口已被占用

maven-pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!--坐标代表本项目-->
    <groupId>com.noma.cn</groupId>
    <artifactId>hello-maven01</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!--打包方式-->
    <!--<packaging>war</packaging>-->
    <!--<packaging>pom</packaging>-->

    <!--加载插件-->
    <!--在pom文件中 添加comcat7插件 -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>

                <configuration>
                    <!-- 项目访问路径 本例:localhost:9090, 如果配置的aa,则访问路径为localhost:9090/aa -->
                    <path>/</path>
                    <port>8888</port>
                    <uriEncoding>UTF-8</uriEncoding><!-- 非必需项 -->
                </configuration>
            </plugin>

            <!--maven-jetty插件的方式-->
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.0.M2</version>
                <configuration>
                    <webAppConfig>
                        <!--配置根路径-->
                        <contextPath>/</contextPath>
                    </webAppConfig>
                    <httpConnector>
                        <!--配置端口-->
                        <port>9999</port>
                    </httpConnector>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
View Code

错误:

[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run (default-cli) on project hello-maven01: Failure: Address already in use: bind -> [Help 1]

 

 解决:

一:改端口号:

二:关掉端口进程:

1. 使用windows命令行查看占用的端口信息

netstat -aon | findstr 端口

2.根据PID找到对应的程序

tasklist | findstr PID

3.强制终止程序

taskkill /f /t /im java.exe

 

posted on 2022-02-28 22:07  NOMA~  阅读(99)  评论(0编辑  收藏  举报

导航