|
@@ -0,0 +1,43 @@
|
|
|
+
|
|
|
+package com.baomidou.mybatisplus.test.h2.issues.repositoryscan;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
|
|
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
|
|
+import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
+import org.h2.Driver;
|
|
|
+import org.mybatis.spring.annotation.MapperScan;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.ComponentScan;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.jdbc.datasource.SimpleDriverDataSource;
|
|
|
+import org.springframework.stereotype.Repository;
|
|
|
+
|
|
|
+import javax.sql.DataSource;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author nieqiurong
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+@ComponentScan("com.baomidou.mybatisplus.test.h2.issues.repositoryscan")
|
|
|
+@MapperScan(value = "com.baomidou.mybatisplus.test.h2.issues.repositoryscan.mapper", annotationClass = Repository.class)
|
|
|
+public class AppConfigWithMapperScan {
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public DataSource dataSource() {
|
|
|
+ SimpleDriverDataSource dataSource = new SimpleDriverDataSource();
|
|
|
+ dataSource.setDriver(new Driver());
|
|
|
+ dataSource.setUrl("jdbc:h2:mem:testa;MODE=mysql;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
|
|
|
+ dataSource.setUsername("sa");
|
|
|
+ dataSource.setPassword("");
|
|
|
+ return dataSource;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
|
|
|
+ MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
|
|
+ mybatisSqlSessionFactoryBean.setDataSource(dataSource);
|
|
|
+ mybatisSqlSessionFactoryBean.setConfiguration(new MybatisConfiguration());
|
|
|
+ return mybatisSqlSessionFactoryBean.getObject();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|