1.添加jar。首先把默认编译后生成出来的jdbc.jar(通常名称为cas-server-support-jdbc-4.0.0.jar),从cas-server-support-jdbc\target\目录下拷贝到webapp\WEB-INF\lib目录下。
2.打开webapp\WEB-INF目录下的deployerConfigContext.xml,
<!--
<bean id="primaryAuthenticationHandler"
class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">
<property name="users">
<map>
<entry key="admin" value="admin"/>
</map>
</property>
</bean>
-->
替换为:
<bean id="primaryAuthenticationHandler" class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="dataSourceForMySql" ></property>
<property name="sql" value="select password from member where phone =?" ></property>
<!-- <property name="passwordEncoder" ref="RS10Md5PasswordEncoder" /> -->
</bean>
<bean id="dataSourceForMySql" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/fyjf</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>root</value></property>
</bean>