在过去,我在IntelliJ的Maven面板中看到过一个 Jetty 子菜单。在 * 插件 , 插件 * 和 * 插件 * 三个层次结构中,* 插件 * 元素列表将包括一个 Jetty 项目。我可以展开该项目以查看Jetty命令,如 * 运行 *。双击该项目将使用Jetty运行Web应用程序项目。
在IntelliJ IDEA 2023.3.2(Ultimate Edition)中创建我自己的简单示例Web应用程序项目时,我已经配置了Jetty Maven插件。这很有效,因为我可以按两次Control键来启动IntelliJ Run anything,在那里我可以执行mvn jetty:run
来成功运行我的Web应用程序。
但是,在Maven面板>插件列表下没有命令的 Jetty 子列表。
的数据
👉🏽如何获取要在IntelliJ的Maven窗口窗格中显示的Jetty命令列表?
在我的POM中,我有一个最新版本的the Jetty Maven plugin的元素:
<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>
型
1条答案
按热度按时间vu8f3i0k1#
将
<plugin>
元素移动到<pluginManagement>
的 * 外部 *更改POM,将
jetty-ee10-maven-plugin
的<plugin>
元素移动到分组元素<pluginManagement>
之外。这确实有效;jetty 命令组确实出现在IntelliJ中Maven窗口窗格的 Plugins 层次结构中。
x1c 0d1x的数据
**警告:**我不知道POM中这个不同位置的缺点或影响。我不理解the purpose of
<pluginManagement>
。所以你的新POM看起来像这样:
字符串
这个解决方法的功劳要归功于JavaPointers.com上的页面How to add Maven Jetty Plugin。引用如下:
其他开发人员遇到了一个问题,其中IntelliJ没有在 Maven 选项卡中显示Jetty插件。这可能是因为您在
PluginManagement
部分下添加了Jetty插件。要解决此问题,请将Jetty插件移到外部,并将其添加为build > plugins
部分的子项。