maven 无法识别 jetty 已安装

maven fails to recognize jetty is installed

GCP上的鲜肉新手/

上的Maven

我下载了 GCP getting-started-java github 示例并想要 运行 书架示例。

当我查看多个 POM 文件时,我发现每个文件都引用了 GCP 的项目 ID。

我不能使用相同的项目 ID,因为它们是唯一的,就像 GCP 存储桶名称一样。

所以,当我 运行

gcloud init

和 select 或创建一个配置并使用唯一的项目 ID 创建我自己的项目, 会自动覆盖项目 ID 的每个 POM 文件定义吗?或者我需要做一些 maven clean 命令来改变它吗???

嗯...当我在每个文件夹中进行 RTFM 时,它会说

mvn clean jetty:run-exploded -Dbookshelf.bucket=MY-BUCKET

哎呀甚至尝试过:

mvn jetty:run

我得到一个构建失败,上面写着:

[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups

所以...我

brew install jetty

然后到 'get started' jetty 说我必须将 'plug in' 详细信息复制到我的 POM 文件中...哪一个,因为有几个??

但是当我安装VS Code插件时,它已经更新了所有的POM文件;我仍然收到 "No plugin found for prefix 'jetty'" 错误

我想我会停止这个问题:

如何让 maven 'know' 安装并使用码头?

当您使用 shorthand 插件目标时 jetty:run-explodedjetty:run maven 正在尝试查找插件。此 shorthand 表单需要解析 groupId:artifactId:version:goal 才能 运行.

它的全称是...

$ mvn org.eclipse.jetty:jetty-maven-plugin:9.4.15.v20190215:run

要解决此问题,只需将插件添加到您的 pom.xml

<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
                      https://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <build>
    ...
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>9.4.15.v20190215</version>
        </plugin>
      </plugins>
    </pluginManagement>
    ...
  </build>
</project>

当您使用 shorthand 语法时,上面将始终使用特定版本的 jetty-maven-plugin。

或者,对使用哪个版本的控制较少,是设置一个 pluginGroup in maven's $HOME/.m2/settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <pluginGroups>
    <pluginGroup>org.eclipse.jetty</pluginGroup>
  </pluginGroups>
  ...
</settings>