Spring在返回单例bean的缓存实例时太长了

时间:2015-04-14 13:34:10

标签: java spring spring-mvc spring-security

这是我的日志消息。

09:24:21.633 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy#0'
09:24:21.633 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean '(inner bean)#32311ede'
09:24:21.637 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean '(inner bean)#32311ede'
09:24:21.637 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.security.authentication.ProviderManager#0'
09:24:21.638 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.security.authentication.ProviderManager#0'
09:24:21.638 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.security.authentication.AnonymousAuthenticationProvider#0'
09:24:21.638 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.security.authentication.AnonymousAuthenticationProvider#0'
09:24:21.640 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.security.authentication.AnonymousAuthenticationProvider#0' to allow for resolving potential circular references
09:24:21.643 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'org.springframework.security.authentication.AnonymousAuthenticationProvider#0'

09:24:21.643 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.security.authentication.AnonymousAuthenticationProvider#0'
09:24:21.643 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'
09:24:21.643 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'
09:24:21.644 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' to allow for resolving potential circular references
09:24:21.647 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'
09:24:21.647 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.security.authenticationManager'
09:24:21.648 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.security.authenticationManager'
09:24:21.648 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'
09:24:21.648 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'
09:24:21.652 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' to allow for resolving potential circular references
09:24:21.700 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'jasyptPasswordEncryption
09:24:21.702 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'tenantDetailsService'

这是我的Spring Security配置

                                      

                                

和上述课程

@Service
public class TenantDetailsService implements UserDetailsService {

    @Autowired
    private UserAccountRepo userAccountRepo;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        UserAccount account = userAccountRepo.findByUsername(username);
        if(account != null){
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
            authorities.add(new SimpleGrantedAuthority(account.getRole()));
            return new TenantUserDetails(account.getUsername(),
                    account.getPassword(),authorities,account.getTenantCode());
        }else{
            throw new UsernameNotFoundException("Bad Credentials");
        }
    }
}

jasypt密码加密服务

@Service
public class JasyptPasswordEncryptionService implements PasswordEncryptionService,PasswordEncoder{

    private StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();

    @Override
    public String encode(CharSequence rawPassword) {
        return passwordEncryptor.encryptPassword(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword,String  encodedPassword) {
        try{
            return passwordEncryptor.checkPassword(rawPassword.toString(), encodedPassword);
        }catch (EncryptionOperationNotPossibleException encryptionOperationNotPossibleException){
            return  false;
        }
    }
}

问题是它已经花了我30分钟,而且构建仍然没有完成,我被困在那两行。但是,我将我的身份验证管理器更改为弹出默认身份验证管理器并且工作正常

我的身份验证管理器配置错误吗?

修改 我现有的配置适用于我的Windows机器,但是在ubuntu 14.04上它没有

0 个答案:

没有答案