ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.91k stars 522 forks source link

String Encryptor custom Bean not found with name 'jasyptStringEncryptor' even when bean exists in the config #51

Closed SureshTak closed 7 years ago

SureshTak commented 7 years ago

Hi, I am using jasypt spring boot starter plug in and added custom String Encryptor bean defination to the AppConfig file but still I get the String Encryptor custom Bean not found with name 'jasyptStringEncryptor' error in the logs and always it picking up default jasypt encryption config values.

Please help me why spring not picking up my custom encryption config values.

Spring boot version is -1.5.4.RELEASE Jayspt version is -com.github.ulisesbocchio:jasypt-spring-boot-starter:1.12

My Bean definition looks like below.

@Bean(name="jasyptStringEncryptor")
    static public PooledPBEStringEncryptor stringEncryptor() {
        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPassword("password");
        config.setAlgorithm("PBEWithMD5AndDES");
          @@config.setKeyObtentionIterations("1000");
        config.setPoolSize("1");
        config.setProviderName("SunJCE");
        config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
        config.setStringOutputType("base64");
        encryptor.setConfig(config);
        return encryptor;
    }

log: 2017-06-20 21:53:29.921 INFO 16560 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jasyptStringEncryptor' with a different defin ition: replacing [Root bean: class [com....AppConfig]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factor yBeanName=null; factoryMethodName=stringEncryptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com////AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.ulisesbocchio.jasyptspringboot.con figuration.EncryptablePropertyResolverConfiguration; factoryMethodName=stringEncryptor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/ulisesbo cchio/jasyptspringboot/configuration/EncryptablePropertyResolverConfiguration.class]] 2017-06-20 21:53:29.925 WARN 16560 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition 'beanNamePlaceholderRegistryPostProc essor' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declari ng such methods as 'static'.

2017-06-20 21:53:31.406 INFO 16560 --- [ main] EncryptablePropertyResolverConfiguration : String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initiali zing String Encryptor based on properties with name 'jasyptStringEncryptor' 2017-06-20 21:53:31.425 INFO 16560 --- [ main] c.u.j.encryptor.DefaultLazyEncryptor : Encryptor config not found for property jasypt.encryptor.algorithm, using default value: PBEWithMD5AndDES

SureshTak commented 7 years ago

@ulisesbocchio

ulisesbocchio commented 7 years ago

this is fixed in MASTER, dup of #48

SureshTak commented 7 years ago

Thanks for fix. I will pull the latest library.