0

尝试执行 jsp 页面时收到错误消息“只能导入类型”。

我收到错误消息:“只能导入一个类型。com.adobe.cq.TestServiceImpl 解析为 adobe day cq 中的一个包

我创建了一个捆绑包并安装在 felix 控制台中。捆绑包的状态也是活动的。而且它在服务和组件控制台中都可用。

这是我在 com.adobe.cq 包中的 TestServiceImpl 类

    package com.adobe.cq;


import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Properties;
//src.component
//declares the class component. This will provide a wrapped ManagedService component in the OSGI container. 

//src.service interface="SampleService" 
//declares the service we are offering. Actually, the interface attribute is superflous, as by default, all implemented Interfaces are used. 

/**
@scr.component
@scr.service interface="testService"
*/
@Component(immediate = true, metatype = true)
@Service
@Properties( {
        @Property(name = "service.description", value = "abcd"),
        @Property(name = "label", value = "myLabel") })
public class TestServiceImpl implements TestService {
 public String sayHello() {
     return "Hello World!";
 }
}

这是我的jsp代码。

    <%@include file="/libs/foundation/global.jsp"%><%
%><%@include file="/apps/mine/includes/functions.jsp"%><%
%><%@ page import="com.adobe.cq.TestServiceImpl,
                org.apache.sling.api.SlingHttpServletRequest,
                java.util.List"%><%
%><%
    SlingHttpServletRequest r = (SlingHttpServletRequest)request;    
    TestServiceImpl testService = sling.getService(TestServiceImpl.class);
    out.println("testService:::"+testService);
%>
<div id="te-nav" style="display:block !important;">
</div>

是因为在 TestServiceImpl 类中使用了注解吗?

你能告诉我如何解决吗?

问候, 安德森

4

0 回答 0