java - 无法在 CRXDE eclipse 中解析类

标签 java eclipse jsp aem crx

我是 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 文件夹中的 jar 是否以依赖项的形式可用。如果没有,请在 pom.xml 中添加依赖项。要检查依赖项的正确版本,请使用以下链接:

   localhost:4502/system/console/depfinder

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

关于java - 无法在 CRXDE eclipse 中解析类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28190055/

相关文章:

java - 在java spring中使用ActiveMq为多个项目创建公共(public)代理

java - 钱包的java代码中的标识符错误

java - 如何使用 Eclipse 查找 Java 代码中潜在的数字溢出?

java - 通过另一个类使用 JSP 连接到 MySQL DB

java - 使用 jSTL 访问类属性

java - iFrame没有source属性但嵌入html标签

java - 如何在java中将千分之一或更低的字符串格式化为日期?

java - 一旦我执行了一项功能,如何让控制台菜单重复,以便我可以在不关闭程序的情况下执行另一项功能?

eclipse - eclipse中statet找不到rj包

eclipse - 为什么Eclipse不将第三方库源文件附加到面向WTP的Gradle项目?