IntelliJ Maven 面板“插件”区域中的 Jetty 子菜单

问题描述 投票:0回答:1

以前,我在IntelliJ的Maven面板中看到过一个Jetty子菜单。在 LifecyclePluginsDependency 层次结构中,Plugins 元素列表将包含 Jetty 项。我可以展开该项目以查看 Jetty 命令,例如 Run。双击该项目将使用 Jetty 运行 Web 应用程序项目。

在 IntelliJ IDEA 2023.3.2(终极版)中创建我自己的简单示例 Web 应用程序项目时,我配置了 Jetty Maven 插件。这是有效的,因为我可以按两次 Control 键来调出 IntelliJ Run everything,我可以在其中执行

mvn jetty:run
来成功运行我的 Web 应用程序。

但是,Maven 面板 > 插件列表下没有 Jetty 命令子列表。

👉🏽 如何获取要在 IntelliJ 的 Maven 窗口窗格中显示的 Jetty 命令列表?

在我的 POM 中,我有一个用于最新版本的 Jetty Maven 插件的元素:

<plugin>
    <groupId>org.eclipse.jetty.ee10</groupId>
    <artifactId>jetty-ee10-maven-plugin</artifactId>
    <version>12.0.5</version>
</plugin>

这是完整的 POM:

<?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>org.example</groupId>
    <artifactId>hello-world</artifactId>
    <version>0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>Jetty HellowWorld Webapp</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>21</maven.compiler.release>
        <jettyVersion>12.0.5</jettyVersion>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.10.1</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/jakarta.servlet.jsp/jakarta.servlet.jsp-api -->
        <dependency>
            <groupId>jakarta.servlet.jsp</groupId>
            <artifactId>jakarta.servlet.jsp-api</artifactId>
            <version>3.0.0</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>ExServletMySQL</finalName>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.3.2</version>
                </plugin>
                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>

                <plugin>
                    <groupId>org.eclipse.jetty.ee10</groupId>
                    <artifactId>jetty-ee10-maven-plugin</artifactId>
                    <version>12.0.5</version>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>
</project>
maven intellij-idea servlets jetty
1个回答
0
投票

<plugin>
元素移动到 <pluginManagement>
outside

更改 POM 以将

<plugin>
元素移至分组元素
jetty-ee10-maven-plugin
之外。
这确实有效; 

jetty

组命令确实出现在 IntelliJ 中 Maven 窗口窗格的 Plugins 层次结构中。但我不知道 POM 中这个不同位置的缺点或影响。 所以你的新 POM 看起来像这样:

<pluginManagement>

此解决方法的功劳归功于 JavaPointers.com 上的人员的页面,

如何添加 Maven Jetty 插件。引用:

其他开发人员遇到了一个问题,其中 IntelliJ 未在
Maven

选项卡中显示 Jetty 插件。可能是因为您在 <?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>org.example</groupId> <artifactId>hello-world</artifactId> <version>0.1-SNAPSHOT</version> <packaging>war</packaging> <name>Jetty HellowWorld Webapp</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.release>21</maven.compiler.release> </properties> <dependencies> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.10.1</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api --> <dependency> <groupId>jakarta.servlet</groupId> <artifactId>jakarta.servlet-api</artifactId> <version>6.0.0</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/jakarta.servlet.jsp/jakarta.servlet.jsp-api --> <dependency> <groupId>jakarta.servlet.jsp</groupId> <artifactId>jakarta.servlet.jsp-api</artifactId> <version>3.0.0</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>ExServletMySQL</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.3.2</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.3.1</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.1.2</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>3.1.1</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>3.1.1</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.eclipse.jetty.ee10</groupId> <artifactId>jetty-ee10-maven-plugin</artifactId> <version>12.0.5</version> <configuration> <httpConnector> <port>8080</port> </httpConnector> </configuration> </plugin> </plugins> </build> </project> 部分下添加了 Jetty 插件。要解决此问题,请将 jetty 插件移到外部,然后将其作为子项添加到

PluginManagement
部分。

    

© www.soinside.com 2019 - 2024. All rights reserved.