org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为' userDepartment'的bean时出错。

时间:2017-07-07 02:52:14

标签: java spring

我是Spring的新手,我正在尝试将Conversation Scope用于我的应用程序。

ConversationScopedBacking.java

import java.io.Serializable;

import javax.enterprise.context.Conversation;
import javax.faces.context.FacesContext;
import javax.inject.Inject;

public abstract class ConversationScopedBacking implements Serializable {

    private static final long serialVersionUID = 811730530704553468L;

    @Inject
    private Conversation conversation;

    public void beginConversation() {
        if (conversation.isTransient()) {
            conversation.begin();
        }
    }

    public void endConversation() {
        if (!conversation.isTransient()) {
            conversation.end();
        }
    }

    public String getConversationId() {
        return conversation.getId();
    }

    protected boolean isTransient() {
        return conversation.isTransient();
    }

    public void initialize() {
        beginConversation();
    }

    protected void setFlashAttribute(final String key, final Object value) {
        FacesContext.getCurrentInstance().getExternalContext().getFlash()
                .put(key, value);
    }

    protected Object getFlashAttribute(final String key) {
        return FacesContext.getCurrentInstance().getExternalContext()
                .getFlash().get(key);
    }

}

UserDepartmentBacking.java

import java.util.List;

import javax.enterprise.context.ConversationScoped;
import javax.faces.bean.ManagedProperty;
import javax.inject.Named;

import org.primefaces.event.SelectEvent;

import com.bsp.dashboard.model.Bank;


@Named("userDepartment")
@ConversationScoped
public class UserDepartmentBacking extends ConversationScopedBacking {

    private static final long serialVersionUID = -472612538895549587L;

    private List<Bank> instList;
    private Bank selectedInst;
    private Bank selectedInstF;
    private Bank selectedExtr;
    private Bank selectedSV;
    private Bank selectedRecon;
    private Bank selectedDBU;
    private Bank selectedFin;

    @ManagedProperty("#{received}")
    private Received received;

    @Override
    public void initialize() {
        super.initialize();

        instList = received.getReceivedList();
    }

    public List<Bank> getInstList() {
        return instList;
    }

    public Bank getSelectedInst() {
        return selectedInst;
    }

    public void setSelectedInst(Bank selectedInst) {
        this.selectedInst = selectedInst;
    }

    public Bank getSelectedInstF() {
        return selectedInstF;
    }

    public void setSelectedInstF(Bank selectedInstF) {
        this.selectedInstF = selectedInstF;
    }

    public Bank getSelectedExtr() {
        return selectedExtr;
    }

    public void setSelectedExtr(Bank selectedExtr) {
        this.selectedExtr = selectedExtr;
    }

    public Bank getSelectedSV() {
        return selectedSV;
    }

    public void setSelectedSV(Bank selectedSV) {
        this.selectedSV = selectedSV;
    }

    public Bank getSelectedRecon() {
        return selectedRecon;
    }

    public void setSelectedRecon(Bank selectedRecon) {
        this.selectedRecon = selectedRecon;
    }

    public Bank getSelectedDBU() {
        return selectedDBU;
    }

    public void setSelectedDBU(Bank selectedDBU) {
        this.selectedDBU = selectedDBU;
    }

    public Bank getSelectedFin() {
        return selectedFin;
    }

    public void setSelectedFin(Bank selectedFin) {
        this.selectedFin = selectedFin;
    }

    public void onRowSelect(SelectEvent event) {
        selectedInst = (Bank) event.getObject();
        selectedInstF = null;
    }

    public void onRowSelectF(SelectEvent event) {
        selectedInstF = (Bank) event.getObject();
        selectedInst = null;
        selectedExtr = null;
        selectedSV = null;
        selectedRecon = null;
        selectedDBU = null;
        selectedFin = null;
    }

    public void view(long index) {
        selectedExtr = null;
        selectedSV = null;
        selectedRecon = null;
        selectedDBU = null;
        selectedFin = null;

        switch ((int)index) {
        case 1:
            selectedExtr = selectedInstF;
            break;
        case 2:
            selectedSV = selectedInstF;
            break;
        case 3:
            selectedRecon = selectedInstF;
            break;
        case 4:
            selectedDBU = selectedInstF;
            break;
        case 5:
            selectedFin = selectedInstF;
            break;
        }
    }

}

我收到了这个错误。

[7/7/17 10:38:55:401 CST] 00000084 FaceletViewDe E   Error Rendering View[/home.xhtml]
                                 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDepartment': Unsatisfied dependency expressed through field 'conversation'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.enterprise.context.Conversation' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1707)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:411)
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:88)
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:170)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:901)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:789)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:427)
    at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:719)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1177)
    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1382)
    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:639)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startModule(ApplicationMgrImpl.java:1693)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl.access$700(ApplicationMgrImpl.java:224)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl$3.run(ApplicationMgrImpl.java:1628)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5477)
    at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5603)
    at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
    at com.ibm.ws.runtime.component.ApplicationMgrImpl._startModule(ApplicationMgrImpl.java:1657)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:272)
    at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1152)
    at java.security.AccessController.doPrivileged(AccessController.java:388)
    at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
    at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1146)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:999)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:847)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:783)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1350)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1243)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.startDeployment(StartDeploymentTask.java:249)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.fineGrainUpdate(StartDeploymentTask.java:200)
    at com.ibm.ws.management.application.sync.StartDeploymentTask.performTask(StartDeploymentTask.java:107)
    at com.ibm.ws.management.application.sync.AppBinaryProcessor$ExpandApp.expand(AppBinaryProcessor.java:1711)
    at com.ibm.ws.management.application.sync.AppBinaryProcessor.postProcessSynchronousExt(AppBinaryProcessor.java:751)
    at com.ibm.ws.management.bla.sync.BLABinaryProcessor.postProcess(BLABinaryProcessor.java:599)
    at com.ibm.ws.management.bla.sync.BLABinaryProcessor.onChangeCompletion(BLABinaryProcessor.java:476)
    at com.ibm.ws.management.bla.sync.BinaryProcessorWrapper.onChangeCompletion(BinaryProcessorWrapper.java:109)
    at com.ibm.ws.management.repository.FileRepository.postNotify(FileRepository.java:1938)
    at com.ibm.ws.management.repository.FileRepository.update(FileRepository.java:1442)
    at com.ibm.ws.management.repository.client.LocalConfigRepositoryClient.update(LocalConfigRepositoryClient.java:189)
    at com.ibm.ws.sm.workspace.impl.WorkSpaceMasterRepositoryAdapter.update(WorkSpaceMasterRepositoryAdapter.java:667)
    at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.update(RepositoryContextImpl.java:1998)
    at com.ibm.ws.sm.workspace.impl.RepositoryContextImpl.synch(RepositoryContextImpl.java:1946)
    at com.ibm.ws.sm.workspace.impl.WorkSpaceImpl.synch(WorkSpaceImpl.java:549)
    at com.ibm.ws.management.configservice.ConfigServiceImpl.save(ConfigServiceImpl.java:720)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:69)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:272)
    at javax.management.modelmbean.RequiredModelMBean$4.run(RequiredModelMBean.java:1152)
    at java.security.AccessController.doPrivileged(AccessController.java:388)
    at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30)
    at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:41)
    at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1146)
    at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:999)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:847)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:783)
    at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:1350)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:1243)
    at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.ibm.ws.management.connector.soap.SOAPConnector.invoke(SOAPConnector.java:488)
    at com.ibm.ws.management.connector.soap.SOAPConnector.service(SOAPConnector.java:322)
    at com.ibm.ws.management.connector.soap.SOAPConnection.handleRequest(SOAPConnection.java:65)
    at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:733)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:532)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)

任何人都可以帮我解决这个问题。我是春天的新人。

0 个答案:

没有答案