【问题标题】:spring security sql-error-codes.xml , no exception trace is foundspring security sql-error-codes.xml ,没有发现异常跟踪
【发布时间】:2019-01-25 07:52:21
【问题描述】:

我已经为我的应用程序配置了 spring 安全性,但由于以下信息被卡在一个地方:org.springframework.beans.factory.xml.XmlBeanDefinitionReader-Loading XML bean definitions from class path resource [org/springframework/jdbc/support /sql-error-codes.xml]。 我有谷歌但找不到原因

我的代码:-

<beans:beans
    xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    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.2.xsd">

    <http security="none" pattern="/login"></http>
    <http auto-config="false" use-expressions="true">
        <intercept-url pattern="/*" access="hasRole('ROLE_USER')" />

        <!-- login-processing-url="" -->
        <form-login login-page="/login" default-target-url="/" authentication-failure-url="/login?error" username-parameter="username" password-parameter="password" />
        <logout logout-success-url="/login?logout" invalidate-session="true" />
    </http>

    <!-- <authentication-manager>
        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource" />
        </authentication-provider>
    </authentication-manager> -->


    <authentication-manager>
        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource"
                users-by-username-query="SELECT USERNAME,PASSWORD,ENABLED from SCOTT.TBL_USERS WHERE USERNAME=?;"
authorities-by-username-query="SELECT u.USERNAME, r.ROLENAME FROM SCOTT.TBL_USERS u,SCOTT.TBL_USER_ROLE r WHERE u.USERNAME = r.USERNAME 
    AND u.USERNAME=?;" />
        </authentication-provider>
    </authentication-manager>

     <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
        <beans:property name="url" value="jdbc:oracle:thin:@192.168.6.147:1521:orcl" />
        <beans:property name="username" value="SCOTT" />
        <beans:property name="password" value="IPORTMAN" />
    </beans:bean> 
</beans:beans>

我已经创建了自己的表格:- 创建表“斯科特”。“用户”( “用户名” VARCHAR2(50) 非空主键, “密码” VARCHAR2(50) 非空, “已启用” NUMBER(22 , 0) NOT NULL );

创建表 "SCOTT"."TBL_USER_ROLE" ( 用户名 varchar(50) 不为空, 权限 varchar(50) 不为空, 约束 fk_authorities_users 外键(用户名)引用“SCOTT”。“TBL_USERS”(用户名)); 我如何追踪问题,为什么我的登录总是失败, 我的登录页面出现了,我已经给出了用户名和密码,但它只是在控制台 sql-error-codes.xml 中弹出。

【问题讨论】:

标签: java spring hibernate spring-security spring-orm


【解决方案1】:
when we are using Oracle database then the table structure is like below
CREATE TABLE users (username VARCHAR(50) PRIMARY KEY, password VARCHAR(50) NOT NULL, enabled VARCHAR(50) NOT NULL)
  create table authorities (
      username varchar(50) not null,
      authority varchar(50) not null,
      constraint fk_authorities_users foreign key(username) references users(username));
      create unique index ix_auth_username on authorities (username,authority);

the problem was in table structure.

【讨论】:

    猜你喜欢
    • 2014-06-17
    • 2018-06-09
    • 1970-01-01
    • 1970-01-01
    • 2018-12-03
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    • 2023-02-05
    相关资源
    最近更新 更多