大家都知道,如果使用ss的官方配置的话,必须用户表严格定义为users,权限表严格定义为authorities,
然而在工程里面可能表的名字不可以严格遵守这种命名规则
这就需要我们进行自定义配置,之前我也找了很多方法,没有解决,最后参考别人的一篇博客,获得了启发,参照这里
在xml里加上
<security:authentication-manager> <security:authentication-provider> <security:jdbc-user-service data-source-ref="dataSource" users-by-username-query = "select username,password,enabled from cpt_users where username = ?" authorities-by-username-query = "select username,authority from cpt_authorities where username = ?" /> </security:authentication-provider> </security:authentication-manager>也就是自己重写查询语句,具体的查询语句请根据数据库来进行书写,即可实现这个功能,
同时也附上我的informix数据库的数据源配置
<!-- 配置数据源 --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.informix.jdbc.IfxDriver"/> <property name="url" value="jdbc:informix-sqli://XXXXXXX"/> <property name="username" value="root"/> <property name="password" value="root"/> </bean>即可