找不到匹配 'quarkus-micrometer-registry-prometheus' 的依赖项

Cannot find a dependency matching 'quarkus-micrometer-registry-prometheus'

我是 Quarkus 的新手,我想用 prometheus 启用 micrometer,所以我添加了依赖项 quarkus-micrometer-registry-prometheus。我输入了这个命令:

./mvnw quarkus:add-extension -Dextensions="quarkus-micrometer-registry-prometheus"

但是returns这个错误:

[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< org.saharsh:sample-quarkus-app >-------------------
[INFO] Building sample-quarkus-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:1.3.2.Final:add-extension (default-cli) @ sample-quarkus-app ---
❌ Cannot find a dependency matching 'quarkus-micrometer-registry-prometheus', maybe a typo?
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.279 s
[INFO] Finished at: 2022-03-29T17:03:05+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.3.2.Final:add-extension (default-cli) on project sample-quarkus-app: Unable to update the pom.xml file: Unable to add extensions -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

关于如何解决这个问题有什么想法吗?

看来您使用的是相当旧的 Quarkus 1.3.2。如果您尝试使用最新版本,它将在 OOTB 时运行。

  1. https://code.quarkus.io
  2. 创建一个新项目
  3. 解压并在项目目录下打开终端
  4. 运行 ./mvnw quarkus:add-extension -Dextensions="quarkus-micrometer-registry-prometheus"
❯ ./mvnw quarkus:add-extension -Dextensions="quarkus-micrometer-registry-prometheus"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 58727  100 58727    0     0   355k      0 --:--:-- --:--:-- --:--:--  372k
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.acme:code-with-quarkus >---------------------
[INFO] Building code-with-quarkus 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.5.Final:add-extension (default-cli) @ code-with-quarkus ---
[INFO] Looking for the newly published extensions in registry.quarkus.io
[INFO] [SUCCESS] ✅  Extension io.quarkus:quarkus-micrometer-registry-prometheus has been installed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.566 s
[INFO] Finished at: 2022-03-30T07:50:37+02:00
[INFO] ------------------------------------------------------------------------