a) 建立數據庫:ssomysql
b) 建立用戶表並初始化用戶spring
1
2
3
4
5
6
7
8
9
10
11
|
CREATE
TABLE
`app_user` (
`username`
varchar
(30)
NOT
NULL
default
''
,
`
password
`
varchar
(45)
NOT
NULL
default
''
,
PRIMARY
KEY
(`username`)
) ENGINE=InnoDB
DEFAULT
CHARSET=utf8;
-- 並添加以下用戶:
INSERT
INTO
`app_user` (`username`,`
password
`)
VALUES
(
'test'
,
'111'
),
(
'user'
,
'222'
),
(
'tom'
,
'333'
),
(
'jim'
,
'000'
);
|
1
2
3
4
5
6
7
8
|
<!--
<bean
class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
-->
<
bean
class
=
"org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
>
<
property
name
=
"sql"
value
=
"select password from app_user where username=?"
/>
<
property
name
=
"dataSource"
ref
=
"dataSource"
/>
</
bean
>
|
b)、beans節點下添加bean:dataSourcesql
1
2
3
4
5
6
|
<
bean
id
=
"dataSource"
class
=
"org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<
property
name
=
"driverClassName"
><
value
>com.mysql.jdbc.Driver</
value
></
property
>
<
property
name
=
"username"
><
value
>root</
value
></
property
>
<
property
name
=
"password"
><
value
>123456</
value
></
property
>
</
bean
>
|
五、重啓tomcat數據庫
cd /bin ./shutdown.sh ./startup.shtomcat
六、登陸服務器:使用3.b步中插入的 服務器
3、可能遇到的問題:
app
一、登陸時提示:Non-Secure-Connectionurl
解決方法:註銷相關代碼便可spa
二、帳號密碼正確可是一直報驗證錯誤:重啓tomcat便可.net