Skip to content

Commit 31b7a1d

Browse files
committed
fix for http://code.google.com/p/mybatis/issues/detail?id=572 . The MapperScannerConfigurer calls post-processing on other beans during its own initialization.
1 parent 6ed5a3a commit 31b7a1d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/org/mybatis/spring/mapper/MapperScannerConfigurer.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public class MapperScannerConfigurer implements BeanDefinitionRegistryPostProces
117117

118118
private String beanName;
119119

120+
private boolean processPropertyHolders;
121+
120122
/**
121123
* This property lets you set the base package for your mapper interface files.
122124
* <p>
@@ -230,6 +232,16 @@ public void setSqlSessionFactoryBeanName(String sqlSessionFactoryName) {
230232
this.sqlSessionFactoryBeanName = sqlSessionFactoryName;
231233
}
232234

235+
/**
236+
*
237+
* @since 1.1.0
238+
*
239+
* @param processPropertyHolders
240+
*/
241+
public void setProcessPropertyHolders(boolean processPropertyHolders) {
242+
this.processPropertyHolders = processPropertyHolders;
243+
}
244+
233245
/**
234246
* {@inheritDoc}
235247
*/
@@ -261,7 +273,9 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
261273
* {@inheritDoc}
262274
*/
263275
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
264-
processPropertyPlaceHolders();
276+
if (this.processPropertyHolders) {
277+
processPropertyPlaceHolders();
278+
}
265279

266280
Scanner scanner = new Scanner(beanDefinitionRegistry);
267281
scanner.setResourceLoader(this.applicationContext);

src/test/java/org/mybatis/spring/mapper/MapperScannerConfigurerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ public void testScanWithPropertyPlaceholders() {
207207
// use a property placeholder for basePackage
208208
definition.getPropertyValues().removePropertyValue("basePackage");
209209
definition.getPropertyValues().add("basePackage", "${basePackageProperty}");
210+
definition.getPropertyValues().add("processPropertyHolders", true);
210211

211212
// also use a property placeholder for an SqlSessionFactory property
212213
// to make sure the configLocation was setup correctly and MapperScanner did not change

0 commit comments

Comments
 (0)