类 无法在 CRXDE eclipse 中解析

Classes cannot be resolved in CRXDE eclipse

我是 CRXDE 的新手,如果这是一个愚蠢的问题,请原谅我。

CRXDE eclipse 中报告了错误,其中某些 类 丢失或无法解决。请参阅下面的代码 (错误消息已添加为注释):

在 libs/wcm/core/components/designer/designer.css.java

import com.day.text.Text; //The import com.day.text cannot be resolved
import org.apache.sling.api.SlingHttpServletRequest;//The import org.apache.sling.api.SlingHttpServletRequest cannot be resolved
import org.apache.sling.api.SlingHttpServletResponse;//The import org.apache.sling.api.SlingHttpServletResponse cannot be resolved
import org.apache.sling.api.resource.Resource;//The import org.apache.sling.api.resource.Resource cannot be resolved
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;//The import org.apache.sling.api.servlets cannot be resolved
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Renders the computed css styles
 */
public class designer_css extends SlingSafeMethodsServlet {//The public type designer_css must be defined in its own file ; SlingSafeMethodsServlet cannot be resolved to a type

    /**
     * default logger
     */
    private static final Logger log = LoggerFactory.getLogger(designer_css.class);

    protected void doGet(SlingHttpServletRequest req, SlingHttpServletResponse resp) //SlingHttpServletRequest cannot be resolved to a type; SlingHttpServletResponse cannot be resolved to a type
            throws ServletException, IOException {
        resp.setContentType("text/css");
        resp.setCharacterEncoding("utf-8");

这也发生在 jsp 文件中,例如: 在 libs/cq/core/components/login/login.jsp

<%@page session="false"
        contentType="text/html; charset=utf-8"
        import="org.apache.sling.api.resource.Resource, //The import org.apache.sling.api cannot be resolved
                org.apache.commons.lang.StringUtils,//The import org.apache.commons.lang cannot be resolved
                com.day.cq.i18n.I18n"%><%
%><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><cq:defineObjects /><%!

private String getOverlayCssPath(Resource resource, String fileName) {
    String path = resource.getPath() + fileName;
    // snip off 1. segment
    path = path.substring(path.indexOf("/", 1)+1);
    Resource res = resource.getResourceResolver().getResource(path);
    if (res != null) {
        return res.getPath();
    } else {
        return path;
    }
}

而且我不确定应该为这些丢失的包添加哪个 jar 文件以及在哪里可以找到它们。

CRXDE Lite 一切正常。

有谁知道如何解决这个问题?提前致谢。

-唐纳德

首先,如果您使用的是 maven,则需要检查 .m2 文件夹中是否有依赖关系形式的 jars。如果没有,请在您内部添加依赖项 pom.xml。要检查依赖项的正确版本,请使用 link :

   localhost:4502/system/console/depfinder

并提及 package/class 名称,例如 org.apache.sling.api.SlingHttpServletRequest。然后使用 mvn clean 重建你的项目...这可能会解决你的 bundle 类.

问题