如何在 Quarkus Native 构建中正确声明 ResourceBundle? (MyFaces 扩展)

问题描述 投票:0回答:1

我正在尝试将 Java 类作为资源包加载到

faces-config.xml
:

<application>
    <resource-bundle>
        <base-name>app.LanguageBundle</base-name>
        <var>msg</var>
    </resource-bundle>
</application>

该类用

@RegisterForReflection
注释,但似乎这不足以加载它。

我收到以下错误

java.util.MissingResourceException: Can't find bundle for base name app.LanguageBundle, locale de_DE
    at [email protected]/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2059)
    at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1697)
    at [email protected]/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1600)
    at [email protected]/java.util.ResourceBundle.getBundle(ResourceBundle.java:1283)
    at org.apache.myfaces.application.ApplicationImpl.getResourceBundle(ApplicationImpl.java:417)
    at org.apache.myfaces.application.ApplicationImpl.getResourceBundle(ApplicationImpl.java:381)
    at jakarta.faces.application.ApplicationWrapper.getResourceBundle(ApplicationWrapper.java:263)
    at jakarta.faces.application.ApplicationWrapper.getResourceBundle(ApplicationWrapper.java:263)
    at org.apache.myfaces.el.resolver.ResourceBundleResolver.getResourceBundle(ResourceBundleResolver.java:212)
    at org.apache.myfaces.el.resolver.ResourceBundleResolver.getValue(ResourceBundleResolver.java:132)
    at jakarta.el.CompositeELResolver.getValue(CompositeELResolver.java:136)
    at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:94)
    at org.apache.el.parser.AstValue.getValue(AstValue.java:137)
    at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
    at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:100)
    at org.apache.myfaces.view.facelets.el.ELText$ELTextVariable.writeText(ELText.java:238)
    at org.apache.myfaces.view.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
    at org.apache.myfaces.view.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:46)
    at org.apache.myfaces.view.facelets.compiler.UILeaf.encodeAll(UILeaf.java:362)

我在将 Java 类注册为资源包时找到了这个参考,但我不知道如何在应用程序中使用它,而不是扩展。

jakarta-ee quarkus graalvm myfaces quarkus-native
1个回答
0
投票

是的,您可以在我们的 Quarkus Faces 演示应用程序中看到:https://github.com/melloware/quarkus-faces

捆绑包进入

src/main/resources/
https://github.com/melloware/quarkus-faces/blob/main/src/main/resources/build.properties

及其在

faces-config.xml
中引用:https://github.com/melloware/quarkus-faces/blob/efd3fd4f3a8de6ab83f1bd0ce93d0f3345e7659e/src/main/resources/META-INF/faces-config.xml#L38-L41

<resource-bundle>
  <base-name>build</base-name>
  <var>build</var>
</resource-bundle>
© www.soinside.com 2019 - 2024. All rights reserved.