title: spring boot not loading correct Jasypt application.properties for environment
body: <p>I am trying to implement Jasypt in my Spring Boot 1.4 application because it seems overkill to use Spring Cloud Config for a small app like this. However, I am clearly not understanding how Spring Boot determines which environment its running, and use the appropriate properties file.  I need to encrypt the datasource properties stored such as:</p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/myschema
  spring.datasource.username=myuser
  spring.datasource.password=ENC(ZwXHbQl^8c2U)
  spring.datasource.driverClassName=org.postgresql.Driver
  spring.jpa.database=POSTGRESQL
  </code></pre>
  
  <p>In my <code>project/config/</code> directory I have three files:</p>
  
  <ul>
  <li><code>application.properties</code>: single entry of: <code>spring.profiles.active=local</code></li>
  <li><code>application-local.properties</code>: config values for develop, including local db credentials</li>
  <li><code>application-test.properties</code>: config values for test env such as db credentials, etc</li>
  <li><code>application-prod.properties</code>: config values for production env such as db credentials, etc</li>
  </ul>
  
  <p>I am importing Jasypt via:</p>
  
  <blockquote>
    <p>compile group: 'com.github.ulisesbocchio', name:
    'jasypt-spring-boot-starter', version: '1.7'</p>
  </blockquote>
  
  <p>I run local Spock / Goovy integration tests, so I annotate my Base Test class with </p>
  
  <blockquote>
    <p>@ActiveProfiles("local, test")</p>
  </blockquote>
  
  <p>But that didn't seem to pickup the properties file.<br>
  &lt;<strong>FIXED</strong>> by adding <code>@ActiveProfiles(["local", "test"])</code></p>
  
  <p>I added the <strong>/config/application.properties</strong> file to set the </p>
  
  <blockquote>
    <p>spring.profiles.active=local
    jasypt.encryptor.password=</p>
  </blockquote>
  
  <p>I have looked at the documentation for how Jasypt works, so I can try and understand how to encrypt my db credentials per environment.  Also, I have been able to figure out how to get the proper properties file loaded to test the encryption yet.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It would appear that the proper *.properties file is being loaded now (thanks to the great feedback!) but the database password is either not found or not able to be decrypted.  I see the following in the logs:</p>
  
  <pre><code>eEncryptablePropertySourcesPostProcessor : Post-processing PropertySource instances
  c.u.j.c.StringEncryptorConfiguration     : String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing String Encryptor based on properties with name 'jasyptStringEncryptor'
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource commandLineArgs [to EncryptableEnumerablePropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource servletConfigInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource servletContextInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource systemProperties [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
   eEncryptablePropertySourcesPostProcessor : Converting PropertySource systemEnvironment [org.springframework.core.env.SystemEnvironmentPropertySource] to EncryptableMapPropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource random [org.springframework.boot.context.config.RandomValuePropertySource] to EncryptablePropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource applicationConfig: [file:./config/application-local.properties] [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource applicationConfig: [file:./config/application.properties] [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
  eEncryptablePropertySourcesPostProcessor : Converting PropertySource applicationConfig: [classpath:/application.properties] [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
   .c.EncryptablePropertySourcesInitializer : Created Encryptable Property Source 'EncryptedProperties' from locations: [classpath:application.properties]
  
   Encryptor config not found for property jasypt.encryptor.algorithm, using default value: PBEWithMD5AndDES
   c.u.j.c.StringEncryptorConfiguration     : Encryptor config not found for property jasypt.encryptor.keyObtentionIterations, using default value: 1000
  c.u.j.c.StringEncryptorConfiguration     : Encryptor config not found for property jasypt.encryptor.poolSize, using default value: 1
  c.u.j.c.StringEncryptorConfiguration     : Encryptor config not found for property jasypt.encryptor.providerName, using default value: SunJCE
  c.u.j.c.StringEncryptorConfiguration     : Encryptor config not found for property jasypt.encryptor.saltGeneratorClassname, using default value: org.jasypt.salt.RandomSaltGenerator
  c.u.j.c.StringEncryptorConfiguration     : Encryptor config not found for property jasypt.encryptor.stringOutputType, using default value: base64
  j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
  </code></pre>
  
  <p>According to this line:</p>
  
  <pre><code>Property Source 'EncryptedProperties' from locations:[classpath:application.properties]
  </code></pre>
  
  <p>It almost seems like we have to explicitly declare which properties files to search for encrypted values in the @EnableEncryptableProperties( ) annotation, but that doesn't seem to take a list of files or property values, nor do I find anyone saying that needs to be done.</p>