java - PropertyPlaceholderConfigurers loading after parameterized DataSource bean -
at top of application context declare propertyplaceholderconfigurer
... <context:annotation-config/> <context:property-placeholder location="classpath:foo.properties"/> ...
later on declare datasource bean parameterized properties properties file
<bean id="somedatasource" class="oracle.jdbc.pool.oracledatasource" destroy-method="close"> <property name="connectioncachingenabled" value="true"/> <property name="url" value="${database.url}"/> <property name="user" value="${database.user}"/> <property name="password" value="${database.password}"/> </bean>
during deployment notice datasource bean created , connection attempted established before propertyplaceholderconfigurer initialized. that's causing datasource parameterizations not populated.
any idea why might happening?
is there specific order of creation beans? beans initialized before others? there way ensure propertyplaceholderconfigurer loaded before other beans?
it turns out 1 of beans defined mapperscannerconfigurer mybatis references sqlsessionfactory.
the mapperscannerconfigurer can initialize prior propertyplaceholderconfigurer if it's initialized deprecated bean properties
to correct behavior, sqlsessionfactory has referenced using different bean property.
see this related post more details
Comments
Post a Comment