添加了 faces-config.xml 但仍然无法到达目标

Added faces-config.xml but still getting Target Unreachable

我在嵌入式码头上有一个 JSF 应用程序 运行ning。当我从 eclipse 但不是从命令行 运行 它时它有效。我意识到这是因为 eclipse 使用文件夹而 cli 使用 jar。在谷歌搜索后,我假设是因为我的罐子缺少 faces-config.xml。我在 META-INF 文件夹中添加了一个,但我的 xhtml 中的 bean 仍然出现 Target unreachable 错误。

如何检查 JSF 是否确实在扫描我的 jar @ManagedBean

Ps。我用 Maven 构建我的项目的 jar,将它复制到我的 lib 文件夹,然后 运行 它从 cli java -cp "lib\*" com.test.MainSystem

调试后 AnnotationConfiguration 我可以看到 Jetty 只扫描 WEB-INF.

下的 jars

幸运的是,他们提供了一种添加外部罐子的方法。添加这个让我兴奋起来 运行...

WebAppContext webapp = new WebAppContext();

// Add "this" jar to the list of jars to scan for annotations
String jarPath = JettyServer.class.getProtectionDomain().getCodeSource().getLocation().getPath();
webapp.setExtraClasspath(jarPath);