Spring OAuth2资源类未调用

时间:2018-06-26 05:20:41

标签: spring spring-security oauth-2.0 spring-security-oauth2

关于在StackOverflow上提出的以下问题,我包含了一个类 带有@ Configuration,@ EnableResourceServer和@EnableWebSecurity注释。 代码运行良好,但控件未在使用上述方法进行注释的此类中进行。

Do I need resource server with Spring Security OAuth2?

我检查了我的web.xml中是否禁用了安全过滤器。现在,我启用了它们。即使我没有达到预期的结果,但我认为最初的问题已解决。 该问题已解决,但现在我面临另一个问题: HTTP状态500-无法评估表达式'ROLE_USER' 根本原因:org.springframework.expression.spel.SpelEvaluationException:EL1008E:在“ org.springframework.security.web.access.expression.WebSecurityExpressionRoot”类型的对象上找不到属性或字段“ ROLE_USER”-可能不是公共的? >

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>hk-pensions</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:META-INF/spring/*.xml</param-value>
    </context-param>

    <context-param>
        <param-name>defaultHtmlEscape</param-name>
        <param-value>true</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
            </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- Spring Security -->
   <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>  
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

0 个答案:

没有答案