2012-01-05 3 views
0

@Secure annoatation을 컨트롤러 메소드에 추가하고 실행하는 방법은 무엇입니까? \ 작업 공간 \ 보안 목표 명세서 \ 스프링 소스 \ vfabric :스프링 보안에서 @secure annotation을 추가하는 방법

org.springframework.beans.factory.BeanCreationException : 'companyController'파일 [에 정의 된 C 이름을 가진 bean을 생성하는 오류 지금 나는 그것이 예외 등을 가지고 실행할 때 - tc-server-developer-2.6.1.RELEASE \ spring-insight-instance \ wtpwebapps \ BillingEngine \ WEB-INF \ classes \ com \ sesami \ common \ management \ web \ controller \ CompanyController.class] : 빈 초기화에 실패했습니다. ; 중첩 예외는 org.springframework.aop.framework.AopConfigException : 예기치 않은 AOP 예외. 중첩 예외는 org.springframework.beans.factory.BeanCreationException입니다 : 이름이 'org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor # 0'인 bean을 생성하는 중 오류가 발생했습니다 : bean 속성 'accessDecisionManager를 설정하는 동안 bean'accessDecisionManager '에 대한 참조를 해석 할 수 없습니다. '; 중첩 예외는 org.springframework.beans.factory.NoSuchBeanDefinitionException입니다 : 'accessDecisionManager'라는 bean을 정의하지 않았습니다. org.apache.catalina.core.StandardContext.listenerStart (StandardContext.java:4723) at org.apache.catalina.core. (org.springframework.aop.framework.AopConfigException : 예기치 않은 AOP 예외, 중첩 예외는 org.springframework.beans.factory입니다. BeanCreationException : 이름이 'org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor # 0'인 Bean을 생성하는 중 오류가 발생했습니다 : 'accessDecisionManager'bean 속성을 설정하는 동안 bean 'accessDecisionManager'에 대한 참조를 해석 할 수 없으며 중첩 된 예외는 ... 19 개

나는 봄 보안 .XML에게

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd ">

<global-method-security secured-annotations="enabled"> 
<!-- 
<protect-pointcut access="ROLE_ADMIN" 
     expression="execution(* com.sesami.common.management.web.controller.AdminController.*(..))" /> 
     --> 
</global-method-security> 

<!-- URL pattern based security --> 
<http auto-config="false" entry-point-ref="authenticationEntryPoint" 
    use-expressions="true"> 
    <custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER" /> 
    <intercept-url access="hasRole('ROLE_ADMIN')" pattern="/common/admin/**" /> 
    <intercept-url pattern="/common/accounting/**" access="hasRole('ROLE_USER')" /> 
    <intercept-url pattern="/common/billing/**" access="hasRole('ROLE_COMPANY')" /> 
    <logout logout-success-url="/" logout-url="/logout"/> 

</http>......... 

컨트롤러에 다음과 같이 추가하십시오.

@Secure("ROLE_ADMIN") 
@RequestMapping(value = "/common/admin/addAdmin", method = RequestMethod.GET) 
    public String add(ModelMap map) { 
     map.addAttribute(new Administrator()); 
     return "/common/admin/addAdmin"; 
    } 

일부 클래스를 설정하거나 가져올 필요가 있습니까?

답변

1
Cannot resolve reference to bean 'accessDecisionManager' while setting bean property 'accessDecisionManager'; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'accessDecisionManager' is defined 

스프링은 기본 accessDecisionManager를 생성해야하지만 구성 문제로 인해 발생하지 않는 것처럼 보입니다. 킥을 위해서 http config에서 auto-config를 true로 설정하면 어떻게됩니까?

0
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased" xmlns="http://www.springframework.org/schema/beans"> 
    <constructor-arg> 
     <list> 
      <bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" /> 
      <bean class="org.springframework.security.access.vote.RoleVoter" /> 
      <bean class="org.springframework.security.access.vote.AuthenticatedVoter" /> 
     </list> 
    </constructor-arg> 
</bean> 

이 빈을 정의해야합니다.

관련 문제