Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.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 Spring security找不到用户_Java_Spring_Hibernate_Spring Mvc_Spring Security - Fatal编程技术网

Java Spring security找不到用户

Java Spring security找不到用户,java,spring,hibernate,spring-mvc,spring-security,Java,Spring,Hibernate,Spring Mvc,Spring Security,我有以下Spring Security version 3.2.3.RELEASE的代码,它显示了一个自定义登录页面。我输入了正确的用户名和密码,但返回的用户名和密码无效 Hibernate正在运行,因为它显示模式得到更新 Oct 24, 2015 5:12:54 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute INFO: HHH000232: Schema update complete Oct 24, 2015 5:12:54 PM or

我有以下Spring Security version 3.2.3.RELEASE的代码,它显示了一个自定义登录页面。我输入了正确的用户名和密码,但返回的
用户名和密码无效

Hibernate正在运行,因为它显示模式得到更新

Oct 24, 2015 5:12:54 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
Oct 24, 2015 5:12:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 24, 2015 5:12:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 24, 2015 5:12:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 15276 ms
param.errr
${param.error}
为1

        <div class="row">
            <div class="col-sm-7">
                    <c:if test="${not empty param.error}">
                        Invalid username and password.
                    </c:if>
                    <c:if test="${not empty error}">
                        <div class="error">${error}</div>
                    </c:if>
                    <c:if test="${not empty msg}">
                        <div class="msg">${msg}</div>
                    </c:if>
                    <div class="panel-body">
                        <form id="form-login" role="form" method="post" action="<c:url value='/j_spring_security_check' />"
class="relative form form-default"> 
                            <input type="hidden" name="${_csrf.parameterName}"
                                value="${_csrf.token}" />
更新

我添加了
用户服务
,以避免使用数据库,但仍然收到相同的错误

    <authentication-manager>
        <authentication-provider>
            <user-service> <user name="admin@myproject.com" password="secret" authorities="ROLE_ADMIN"/> 
                <user name="user@yahoo.com" password="secret" authorities="ROLE_USER"/> </user-service> 
<!--            <jdbc-user-service data-source-ref="dataSource" -->

<!--                users-by-username-query=" -->
<!--              select username,password,enabled  -->
<!--              from Member where username=?" -->

<!--                authorities-by-username-query=" -->
<!--                       select username  -->
<!--                       from Member where username=?" /> -->
        </authentication-provider>
    </authentication-manager>

甚至在提交表单之前,我也使用了以下代码和,我收到了以下输出

Your login attempt was not successful due to

Bad credentials.




 <c:if test="${not empty SPRING_SECURITY_LAST_EXCEPTION}">
      <font color="red">
        Your login attempt was not successful due to <br/><br/>
        <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>.
      </font>
</c:if>
由于以下原因,您的登录尝试未成功:
糟糕的凭证。
您的登录尝试未成功,原因是

.
You authorities by username查询似乎是错误的,它总是返回用户名。请尝试调试Spring的authmanager以查看发生了什么。@IvanNemeth如何做到这一点?我使用了静态用户名密码,但仍然不起作用。我更新了问题。您需要更多关于抛出的具体authexception的信息,Spring有许多不同的异常类型,但您只看到出现了一些问题。日志文件中没有stacktrace吗?如果没有,请尝试配置日志,或者您可以使用Java IDE(如Eclipse)对其进行调试。这只是一个提示,但如果您在提交表单之前收到它,则意味着它会尝试以某种方式向空用户进行身份验证。BadCredentials不仅在密码错误时抛出,而且在您的示例中,当用户为null或空字符串时,也在找不到用户时抛出。因此,auth过滤器以某种方式应用于您的登录页面,但它不应该。不幸的是,我对这种spring配置不太熟悉。You authorities by username查询似乎是错误的,它总是返回用户名。请尝试调试spring的authmanager以查看发生了什么。@IvanNemeth如何做到这一点?我使用了静态用户名密码,但仍然不起作用。我更新了问题。您需要更多关于抛出的具体authexception的信息,Spring有许多不同的异常类型,但您只看到出现了一些问题。日志文件中没有stacktrace吗?如果没有,请尝试配置日志,或者您可以使用Java IDE(如Eclipse)对其进行调试。这只是一个提示,但如果您在提交表单之前收到它,则意味着它会尝试以某种方式向空用户进行身份验证。BadCredentials不仅在密码错误时抛出,而且在您的示例中,当用户为null或空字符串时,也在找不到用户时抛出。因此,auth过滤器以某种方式应用于您的登录页面,但它不应该。不幸的是,我不太熟悉这种spring配置。
Your login attempt was not successful due to

Bad credentials.




 <c:if test="${not empty SPRING_SECURITY_LAST_EXCEPTION}">
      <font color="red">
        Your login attempt was not successful due to <br/><br/>
        <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>.
      </font>
</c:if>