더북(TheBook)

메시지 리소스 파일(*.properties)로 사용자 정보 가져오기

메시지 리소스 파일에 사용자 이름, 비밀번호, 권한 정보 등을 작성합니다. 그다음 <user-service> 태그 안에 메시지 리소스 파일을 설정하여 사용자 정보를 가져옵니다.

<authentication-manager>
    <authentication-provider>
    <user-service properties="WEB-INF/user/users.properties"/>
    </authentication-provider>
</authentication-manager>

메시지 리소스 파일(*.properties) 작성 예

admin=admin123, ROLE_ADMIN, ROLE_USER
user1=111,ROLE_USER
user2=222,ROLE_USER

데이터베이스에서 사용자 정보 가져오기

<authentication-provider> 태그 안에 <jdbc-user-service> 태그를 사용하여 데이터베이스에서 사용자 정보를 조회하여 가져옵니다.

<authentication-manager>
    <authentication-provider>
    <jdbc-user-service data-source-ref="dataSource"/>
    </authentication-provider>
</authentication-manager>
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.