Spring autowire не работает Нет подходящего bean-компонента типа. Не удалось внедрить автомонтируемые зависимости;JAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Spring autowire не работает Нет подходящего bean-компонента типа. Не удалось внедрить автомонтируемые зависимости;

Сообщение Anonymous »

Эта ошибка появляется всякий раз, когда я пытаюсь запустить свой код.
На прошлой неделе я искал ответ по всему Google, но скоро должен быть сдан мой учебный проект, и мне нужна помощь. У меня есть сканирование @service и компонентов, и я реализовал класс обслуживания. В чем еще может быть проблема. Я проверил весь гугл. Я потратил слишком много дней, пытаясь отладить эту ошибку, но безрезультатно, и мой срок приближается. Пожалуйста, помогите, очень благодарен за любую помощь. :)

org.springframework.beans.factory.BeanCreationException: Error creating bean with name'springSecurityFilterChain' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Cannot resolve reference to bean 'userAuthenticationFilter' while setting bean property 'filterChainMap' with key [Root bean: class [org.springframework.security.web.util.AnyRequestMatcher]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'userAuthenticationFilter' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Cannot resolve reference to bean 'customAuthMgr' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'customAuthMgr' defined in ServletContext resource [/WEB-INF/spring/spring-security.xml]: Cannot resolve reference to bean 'authenticationProvider' while setting bean property 'providers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProvider': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: protected a.b.c.d.projectName.service.UserInfoInterface a.b.c.d.projectName.springweb.security.UserAuthenticationProvider.userInfoInterface; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [a.b.c.d.projectName.service.UserInfoInterface] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:379)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:162)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1681)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:374)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:731)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:616)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1122)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1315)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:623)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:940)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:725)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2046)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:439)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:382)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:110)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:949)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550) Caused by: org.springframework.beans.factory.BeanCreationException:


// класс сущности

package a.b.c.d.projectName.domain.persistence;

import a.b.c.d.projectName.domain.TheRole;
@Entity
@NamedQueries({
@NamedQuery(name="UserInfo.findByUserID",
query="select . . ."
)
})
@Table(name="user_account")
public class UserInfo implements Serializable
{

private static final long serialVersionUID = 1L;

@Id
@Column(name = "userID", length = 20)
private String accountID;

@Column(name = "userDesc", length = 50)
private String userDesc;

// getters setters default constructor toString compare

@ManyToMany
@JoinTable(name="userAcct_userRoles",
joinColumns=@JoinColumn(name="userID"),
inverseJoinColumns=@JoinColumn(name="userRoleID"))

private Collection theRoles;

public Collection getRoles() {
return theRoles;
}

public void setRoles(Collection theRoles) {
this.theRoles = theRoles;
}

}


//интерфейс

package a.b.c.d.projectName.service;

import a.b.c.d.projectName.domain.persistence.UserInfo;

public interface UserInfoInterface {
public UserInfo getUserInfo(String userID);
}


// класс обслуживания

package a.b.c.d.projectName.service.impl;

import a.b.c.d.projectName.domain.persistence.UserInfo;
import a.b.c.d.projectName.service.UserInfoInterface;
. . .

@Service
public class UserInfoImpl implements UserInfoInterface {

@PersistenceContext(unitName = "userInfoPersistenceUnit")
private EntityManager em;

// default constructor...

@Override
public UserInfo getUserInfo(String userID) {

return em.createNamedQuery("UserInfo.findByUserID", UserInfo.class)
.setParameter("userID", userID).getSingleResult();
}
}


// для пружинной безопасности

package a.b.c.d.projectName.security;

import a.b.c.d.projectName.domain.persistence.UserInfo;
import a.b.c.d.projectName.domain.persistence.TheRole;
import a.b.c.d.projectName.service.UserInfoInterface;

. . .

public class UserAuthenticationProvider implements AuthenticationProvider {

@Autowired
protected UserInfoInterface userInfoInterface; //

Подробнее здесь: https://stackoverflow.com/questions/225 ... towired-de
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»