TERASOLUNA Server Framework for Java (5.x)のTutorialをやってみる 〜6.2. Spring Securityチュートリアル〜
今日はこれ*1。
エラーは2つ
一つ目、お決まりのこのエラーを。。。
'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'sampleUserDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sampleUserDetailsService' is defined
条件反射で@Serviceアノテーションをつける。
Bean定義周りって、やっぱり気にくわないのは、
実行時エラーになるところ。コンパイラでなんとかしてほしい。。。(もしくはCOC的な?)
パッケージ配下で包括的に設定してくれたりとかしないかな?!
@Service
public class SampleUserDetailsService implements UserDetailsService {
二つ目、こちらもお決まりのエラーを。。。
重大: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoSuchFieldError: WRITE_DURATIONS_AS_TIMESTAMPS
Keep a copy of the generated servlet class' java code.
ということで、Spring Securityを触ってみる作業終了。
以下あたりのクラスが定義されていて、無駄な実装をしなくていいのと、
Filterの一要素でしかないので、構造的に分離されていてわかり易いのがいいな。
FilterChain設計って結構面倒なので、簡易化されていると嬉しい。
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
mport org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;