Java – @ reference session displays an unsatisfactory error
•
Java
I'm using the sling servlet Because I use javax jcr. Session as a reference
How can I solve this problem?
Solution
javx. jcr. Session is not a service component, so you cannot reference it with @ reference (see) http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/scr-annotations.html#reference ).
If you need the current user session, you can extract it from the slinghttpservletrequest object, as follows:
Session session = slingHttpServletRequest.getResourceResolver() .adaptTo(Session.class);
If you need sessions from other users (technical users with "better" permissions), you can use resourceresolverfactory, which is a service that can be referenced
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码