Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使@autowired在公共portlet(扩展GenericPortlet)中工作,以及如何使spring在没有web上下文的情况下工作(创建bean)_Java_Spring_Liferay 7 - Fatal编程技术网

Java 如何使@autowired在公共portlet(扩展GenericPortlet)中工作,以及如何使spring在没有web上下文的情况下工作(创建bean)

Java 如何使@autowired在公共portlet(扩展GenericPortlet)中工作,以及如何使spring在没有web上下文的情况下工作(创建bean),java,spring,liferay-7,Java,Spring,Liferay 7,我需要让Spring和autowired在没有web上下文的情况下工作 我的portlet的一部分: @Component ( immediate = true, property = { "com.liferay.portlet.display-category=category.sample", "com.liferay.portlet.instanceable=true", "javax.portlet

我需要让Spring和autowired在没有web上下文的情况下工作

我的portlet的一部分:

@Component (
    immediate = true,
    property = {
            "com.liferay.portlet.display-category=category.sample",
            "com.liferay.portlet.instanceable=true",
            "javax.portlet.display-name=Main",
            "javax.portlet.name=" + MainPortletKeys.Main,
            "javax.portlet.security-role-ref=power-user,user"
    },
    service = Portlet.class
)

public class MainPortlet extends GenericPortlet {
    private final DepartmentService departmentService;
    private final Validate<Department> departmentValidate;
    private final EmployeeService employeeService;
    private final Validate<EmployeeDTO> employeeValidate;

    @Autowired
    public MainPortlet(DepartmentService departmentService, Validate<Department> departmentValidate, EmployeeService employeeService, Validate<EmployeeDTO> employeeValidate) {
        this.departmentService = departmentService;
        this.departmentValidate = departmentValidate;
        this.employeeService = employeeService;
        this.employeeValidate = employeeValidate;
    }
2019-04-11 07:36:55.678 WARN  [Framework Event Dispatcher: Equinox
Container: 448cb8d9-4aef-46fb-9142-c4d136b7b531][com_aimprosoft:103]
FrameworkEvent WARNING  org.osgi.framework.ServiceException:
org.apache.felix.scr.impl.manager.SingleComponentManager.getService()
returned a null service object at
org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetServicServiceFactoryUse.java:232)
at
org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)
at
 org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)
at
 org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:524)
at
 org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:464)
at
 org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:624)
at
 com.liferay.portal.osgi.web.portlet.tracker.internal.PortletTracker.addingService(PortletTracker.java:120)
at
com.liferay.portal.osgi.web.portlet.tracker.internal.PortletTracker.addingService(PortletTracker.java:111)
at
 org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943)
at
 org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)