ulisesbocchio / jasypt-spring-boot

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

jasypt-spring-boot-starter 1.16 not able to load encryptablePropertyResolver #66

Closed yogeshjoshiji closed 6 years ago

yogeshjoshiji commented 6 years ago

Not able to load encryptablePropertyResolver so not decripting the password. following is the code :-

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
@SpringBootApplication
@Import(WWMIdentifySubStatusConfig.class)
public class BatchLauncher implements CommandLineRunner {    

    @Autowired
    ApplicationContext appCtx;  

    public static void main(final String[] args) throws Exception {        
        System.setProperty("jasypt.encryptor.password", "GBMiPortal_PORTAL_PUB_KEY");        
        new SpringApplicationBuilder().sources(BatchLauncher.class).run(args);

    } 

    @Override
    public void run(final String... args) throws Exception {        
        Environment environment = this.appCtx.getBean(Environment.class);
        System.out.println("DB password is " + environment.getProperty("spring.datasource.password"));       
        System.exit(0);
    }
}

following dependencies i have in my pom

<dependencies>

        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>1.16</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.16</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.16</version>
        </dependency>
    </dependencies>

getting Below error :-

""2017-11-16 16:46:37 - Running with Spring Boot v1.5.4.RELEASE, Spring v4.3.10.RELEASE
""2017-11-16 16:46:37 - No active profile set, falling back to default profiles: default
""2017-11-16 16:46:37 - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4c40b76e: startup date [Thu Nov 16 16:46:37 IST 2017]; root of context hierarchy
""2017-11-16 16:46:39 - Post-processing PropertySource instances
""2017-11-16 16:46:39 - Converting PropertySource systemProperties [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
""2017-11-16 16:46:39 - Converting PropertySource systemEnvironment [org.springframework.core.env.SystemEnvironmentPropertySource] to EncryptableMapPropertySourceWrapper
""2017-11-16 16:46:39 - Converting PropertySource random [org.springframework.boot.context.config.RandomValuePropertySource] to EncryptablePropertySourceWrapper
""2017-11-16 16:46:39 - Converting PropertySource applicationConfig: [classpath:/application.properties] [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
""2017-11-16 16:46:39 - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
""2017-11-16 16:46:39 - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector
ulisesbocchio commented 6 years ago

those logs are just telling you that you didn't define custom beans for a few of the integration points provided by this library. I don't see any errors in your log and don't see the line being printed: DB password is ... can you paste the full logs?