I have two PropertyPlaceholderConfigurer beans in my project.
Bean A: (Defined as XML)
<bean id="propertyConfigurer" class="org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="order" value="0" />
<property name="locations">
<list>
<value>classpath:/app-dev.properties</value>
<value>classpath:/common-dev.properties</value>
</list>
</property>
</bean>
Bean B: (Defined as Java Config)
@Bean(name = "customPropertiesUtil")
public static CustomPropertiesUtil customPropertiesUtil(StandardPBEStringEncryptor configurationEncryptor) {
CustomPropertiesUtil customPropertiesUtil = new CustomPropertiesUtil ();
customPropertiesUtil.setSystemPropertiesModeName("SYSTEM_PROPERTIES_MODE_OVERRIDE");
customPropertiesUtil.setLocation(new ClassPathResource("mail-dev.properties"));
customPropertiesUtil.setOrder(1);
customPropertiesUtil.setIgnoreUnresolvablePlaceholders(false);
customPropertiesUtil.setStandardPBEStringEncryptor(configurationEncryptor);
return customPropertiesUtil;
}
The bean configurationEncryptor is defined in XML as:
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
Bean B is created in a @Configuration class. The odd thing is, if I remove the parameter injection shown in Bean B, everything works as expected. However, I need the encryptor to resolve some encrypted properties and the only way it is NOT NULL is to inject it using parameter injection. (see Why is an @Autowired field within a @Configuration class null?)
My question is how come, having a bean injected into the @Bean (Bean B) method cause Bean A to fail?