正在安装MyFaces、PrimeFaces和 OmniFaces——未找到Maven依赖项
我正在使用命令行工具来生成一个基于REST的基础项目(那个带有GreetingResource的那个)。
以下是Maven pom.xml中的依赖:
<dependencies>
<!-- Quarkus -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
我打算安装Faces + PrimeFaces + OmniFaces扩展。客户明确要求在原型软件中使用它们。
因此,这意味着要把以下依赖加入到pom.xml(我基本上是从 https://github.com/melloware/quarkus-faces/blob/main/pom.xml 复制的):
<!-- Faces -->
<dependency>
<groupId>org.apache.myfaces.core.extensions.quarkus</groupId>
<artifactId>myfaces-quarkus</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.primefaces</groupId>
<artifactId>quarkus-primefaces</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.omnifaces</groupId>
<artifactId>quarkus-omnifaces</artifactId>
<version>4.1.2</version>
</dependency>
然而,IntelliJ / Maven报错,说找不到它们:
依赖项 'org.apache.myfaces.core.extensions.quarkus' 未找到

这是我的.m2/settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>jboss-public</id>
<repositories>
<repository>
<id>google-maven-central</id>
<name>GCS Maven Central mirror EU</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>jboss-public-repository</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>jboss-public</activeProfile>
</activeProfiles>
</settings>
我原以为把Faces、PF与 OF添加到项目中会是一项相对简单的任务。
我查看了很多示例(不记得所有链接,但确实很多):
https://www.melloware.com/quarkus-faces-using-jsf-with-quarkus/
https://quarkus.io/extensions/org.apache.myfaces.core.extensions.quarkus/myfaces-quarkus/
等等。但它们都无法下载相应的工件。
我还差了什么?
解决方案
没有可言的quarkus-primefaces 4.1.2,因此一个都不起作用也就不足为奇。你复制粘贴的源使用的是quarkus-omnifaces 5.1.0版本和quarkus-primefaces 4.15.13版本。
https://mvnrepository.com/artifact/io.quarkiverse.primefaces/quarkus-primefaces/versions
不过myfaces的那个应该能工作,我刚试时下载也挺顺利的。你可能只需要在IntelliJ中同步Maven项目以让它解析;仅仅把依赖添加到pom中通常不会让IntelliJ自动更新项目,你需要通过IDE右侧默认停靠的标有“maven”的面板来完成刷新/重新加载按钮。