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

nnvyjq4y  于 2024-01-05  发布在  Maven
关注(0)|答案(1)|浏览(171)

在过去,我在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的元素:

  1. <plugin>
  2. <groupId>org.eclipse.jetty.ee10</groupId>
  3. <artifactId>jetty-ee10-maven-plugin</artifactId>
  4. <version>12.0.5</version>
  5. </plugin>

字符串
以下是完整的POM:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>org.example</groupId>
  7. <artifactId>hello-world</artifactId>
  8. <version>0.1-SNAPSHOT</version>
  9. <packaging>war</packaging>
  10. <name>Jetty HellowWorld Webapp</name>
  11. <!-- FIXME change it to the project's website -->
  12. <url>http://www.example.com</url>
  13. <properties>
  14. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  15. <maven.compiler.release>21</maven.compiler.release>
  16. <jettyVersion>12.0.5</jettyVersion>
  17. </properties>
  18. <dependencies>
  19. <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
  20. <dependency>
  21. <groupId>org.junit.jupiter</groupId>
  22. <artifactId>junit-jupiter-api</artifactId>
  23. <version>5.10.1</version>
  24. <scope>test</scope>
  25. </dependency>
  26. <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
  27. <dependency>
  28. <groupId>jakarta.servlet</groupId>
  29. <artifactId>jakarta.servlet-api</artifactId>
  30. <version>6.0.0</version>
  31. <scope>provided</scope>
  32. </dependency>
  33. <!-- https://mvnrepository.com/artifact/jakarta.servlet.jsp/jakarta.servlet.jsp-api -->
  34. <dependency>
  35. <groupId>jakarta.servlet.jsp</groupId>
  36. <artifactId>jakarta.servlet.jsp-api</artifactId>
  37. <version>3.0.0</version>
  38. <scope>provided</scope>
  39. </dependency>
  40. </dependencies>
  41. <build>
  42. <finalName>ExServletMySQL</finalName>
  43. <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
  44. <plugins>
  45. <plugin>
  46. <artifactId>maven-clean-plugin</artifactId>
  47. <version>3.3.2</version>
  48. </plugin>
  49. <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
  50. <plugin>
  51. <artifactId>maven-resources-plugin</artifactId>
  52. <version>3.3.1</version>
  53. </plugin>
  54. <plugin>
  55. <artifactId>maven-compiler-plugin</artifactId>
  56. <version>3.11.0</version>
  57. </plugin>
  58. <plugin>
  59. <artifactId>maven-surefire-plugin</artifactId>
  60. <version>3.1.2</version>
  61. </plugin>
  62. <plugin>
  63. <artifactId>maven-war-plugin</artifactId>
  64. <version>3.2.2</version>
  65. </plugin>
  66. <plugin>
  67. <artifactId>maven-install-plugin</artifactId>
  68. <version>3.1.1</version>
  69. </plugin>
  70. <plugin>
  71. <artifactId>maven-deploy-plugin</artifactId>
  72. <version>3.1.1</version>
  73. </plugin>
  74. <plugin>
  75. <groupId>org.eclipse.jetty.ee10</groupId>
  76. <artifactId>jetty-ee10-maven-plugin</artifactId>
  77. <version>12.0.5</version>
  78. </plugin>
  79. </plugins>
  80. </pluginManagement>
  81. </build>
  82. </project>

vu8f3i0k

vu8f3i0k1#

<plugin>元素移动到<pluginManagement>的 * 外部 *

更改POM,将jetty-ee10-maven-plugin<plugin>元素移动到分组元素<pluginManagement>之外。
这确实有效;jetty 命令组确实出现在IntelliJ中Maven窗口窗格的 Plugins 层次结构中。
x1c 0d1x的数据

**警告:**我不知道POM中这个不同位置的缺点或影响。我不理解the purpose of <pluginManagement>

所以你的新POM看起来像这样:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>org.example</groupId>
  7. <artifactId>hello-world</artifactId>
  8. <version>0.1-SNAPSHOT</version>
  9. <packaging>war</packaging>
  10. <name>Jetty HellowWorld Webapp</name>
  11. <!-- FIXME change it to the project's website -->
  12. <url>http://www.example.com</url>
  13. <properties>
  14. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  15. <maven.compiler.release>21</maven.compiler.release>
  16. </properties>
  17. <dependencies>
  18. <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
  19. <dependency>
  20. <groupId>org.junit.jupiter</groupId>
  21. <artifactId>junit-jupiter-api</artifactId>
  22. <version>5.10.1</version>
  23. <scope>test</scope>
  24. </dependency>
  25. <!-- https://mvnrepository.com/artifact/jakarta.servlet/jakarta.servlet-api -->
  26. <dependency>
  27. <groupId>jakarta.servlet</groupId>
  28. <artifactId>jakarta.servlet-api</artifactId>
  29. <version>6.0.0</version>
  30. <scope>provided</scope>
  31. </dependency>
  32. <!-- https://mvnrepository.com/artifact/jakarta.servlet.jsp/jakarta.servlet.jsp-api -->
  33. <dependency>
  34. <groupId>jakarta.servlet.jsp</groupId>
  35. <artifactId>jakarta.servlet.jsp-api</artifactId>
  36. <version>3.0.0</version>
  37. <scope>provided</scope>
  38. </dependency>
  39. </dependencies>
  40. <build>
  41. <finalName>ExServletMySQL</finalName>
  42. <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
  43. <plugins>
  44. <plugin>
  45. <artifactId>maven-clean-plugin</artifactId>
  46. <version>3.3.2</version>
  47. </plugin>
  48. <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
  49. <plugin>
  50. <artifactId>maven-resources-plugin</artifactId>
  51. <version>3.3.1</version>
  52. </plugin>
  53. <plugin>
  54. <artifactId>maven-compiler-plugin</artifactId>
  55. <version>3.11.0</version>
  56. </plugin>
  57. <plugin>
  58. <artifactId>maven-surefire-plugin</artifactId>
  59. <version>3.1.2</version>
  60. </plugin>
  61. <plugin>
  62. <artifactId>maven-war-plugin</artifactId>
  63. <version>3.2.2</version>
  64. </plugin>
  65. <plugin>
  66. <artifactId>maven-install-plugin</artifactId>
  67. <version>3.1.1</version>
  68. </plugin>
  69. <plugin>
  70. <artifactId>maven-deploy-plugin</artifactId>
  71. <version>3.1.1</version>
  72. </plugin>
  73. </plugins>
  74. </pluginManagement>
  75. <plugins>
  76. <plugin>
  77. <groupId>org.eclipse.jetty.ee10</groupId>
  78. <artifactId>jetty-ee10-maven-plugin</artifactId>
  79. <version>12.0.5</version>
  80. <configuration>
  81. <httpConnector>
  82. <port>8080</port>
  83. </httpConnector>
  84. </configuration>
  85. </plugin>
  86. </plugins>
  87. </build>
  88. </project>

字符串
这个解决方法的功劳要归功于JavaPointers.com上的页面How to add Maven Jetty Plugin。引用如下:
其他开发人员遇到了一个问题,其中IntelliJ没有在 Maven 选项卡中显示Jetty插件。这可能是因为您在PluginManagement部分下添加了Jetty插件。要解决此问题,请将Jetty插件移到外部,并将其添加为build > plugins部分的子项。

展开查看全部

相关问题