R
R
Rocket-API
Search…
数据源配置方式一 (推荐)
继承抽象类com.github.alenfive.rocketapi.datasource.DataSourceManager 如下:
DataSourceDialect的实现类中,其中成员变量:storeApi 有且只能有一个为true,表示Rocket-API运行所需数据存储所在库
1
@Component
2
public class DefaultDataSourceManager extends DataSourceManager {
3
4
@Autowired
5
private JdbcTemplate jdbcTemplate;
6
7
@Autowired
8
private MongoTemplate mongoTemplate;
9
10
@PostConstruct
11
public void init() {
12
Map<String,DataSourceDialect> dialects = new HashMap<>();
13
dialects.put("mysql",new SqlDataSource(jdbcTemplate,false));
14
dialects.put("mongodb",new MongoDataSource(mongoTemplate,true));
15
super.setDialectMap(dialects);
16
}
17
}
Copied!
Last modified 10mo ago
Copy link