diff --git a/src/main/java/com/izeye/throwaway/config/PersistenceConfig.java b/src/main/java/com/izeye/throwaway/config/PersistenceConfig.java index c4dadf3..d5a6d89 100644 --- a/src/main/java/com/izeye/throwaway/config/PersistenceConfig.java +++ b/src/main/java/com/izeye/throwaway/config/PersistenceConfig.java @@ -5,10 +5,12 @@ import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.SqlSessionTemplate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; +import org.springframework.core.io.Resource; import javax.sql.DataSource; @@ -24,12 +26,16 @@ public class PersistenceConfig { @Autowired private MyBatisProperties myBatisProperties; + // FIXME: See https://github.com/spring-projects/spring-boot/issues/15835 + @Value("${mybatis.mapper-locations}") + private Resource[] mapperLocations; + @Bean public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource) { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setDataSource(dataSource); - sqlSessionFactoryBean.setConfigLocation(myBatisProperties.getConfigLocation()); - sqlSessionFactoryBean.setMapperLocations(myBatisProperties.getMapperLocations()); + sqlSessionFactoryBean.setConfigLocation(this.myBatisProperties.getConfigLocation()); + sqlSessionFactoryBean.setMapperLocations(this.mapperLocations); sqlSessionFactoryBean.setVfs(SpringBootVFS.class); return sqlSessionFactoryBean; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 01d9d75..0308dc3 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,6 @@ mybatis.config-location=classpath:mybatis/sqlmap-config.xml -# FIXME: Why doesn't this work? -#mybatis.mapper-locations=classpath:mybatis/mappers/*.xml -mybatis.mapper-locations=classpath:mybatis/mappers/person-repository.xml +mybatis.mapper-locations=classpath:/mybatis/mappers/*.xml + +# FIXME: See https://github.com/spring-projects/spring-boot/issues/15835 +#mybatis.mapper-locations=classpath:mybatis/mappers/person-repository.xml