Access JSF and Primefaces version numbers programmatically

后端 未结 4 468
不知归路
不知归路 2021-01-03 00:52

I use PrimeFaces 3.5.x and Mojarra JSF 2.1.x I would like to access and show the versions of both libraries programmatically.

I use the versions as maven2 properties

4条回答
  •  孤城傲影
    2021-01-03 01:29

    If you need to get the Version on runtime, there will not be any instance of RequestContext. Therefore you could use the ImplementationVersion of the package:

    Package.getPackage("org.primefaces").getImplementationVersion()
    

    If the package cannot be resolved, you can try to resolve the version via PrimeFaces class:

    PrimeFaces.class.getPackage().getImplementationVersion()
    

提交回复
热议问题