Java 在CRXDE eclipse中无法解析类
我是CRXDE的新手,如果这是一个愚蠢的问题,请原谅我 CRXDE eclipse中报告了一些错误,其中一些类丢失或无法解析。请参阅下面的代码(错误MSG作为注释添加): 在libs/wcm/core/components/designer/designer.css.java中Java 在CRXDE eclipse中无法解析类,java,eclipse,jsp,aem,crx,Java,Eclipse,Jsp,Aem,Crx,我是CRXDE的新手,如果这是一个愚蠢的问题,请原谅我 CRXDE eclipse中报告了一些错误,其中一些类丢失或无法解析。请参阅下面的代码(错误MSG作为注释添加): 在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.SlingHttpSe
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;
}
}
首先,如果您使用的是maven,您需要检查.m2文件夹中的JAR是否以依赖项的形式可用。如果没有,则在pom.xml中添加依赖项。要检查依赖项的正确版本,请使用以下链接:
localhost:4502/system/console/depfinder
并提及包/类名,例如org.apache.sling.api.SlingHttpServletRequest。然后使用mvn clean重建您的项目。。。这可能会解决您的捆绑课程问题。谢谢你,伙计,我真的很抱歉没有尽快回复。我尝试了depfinder,并向项目添加了缺少的依赖项,但在下次打开项目时也会出现同样的问题。我也尝试了maven,但不幸的是,我的连接出现了问题,导致mvn清理失败。我将找到一个代理,稍后再试一次。再次感谢你的帮助。我真的很感激。