你好,我有一个小表,我想以表单的形式加载到内存中,List<Country>
以免拉数据库。但是……怎么做才对?
数据源是这样的:
@Configuration
public class DataSourceConfig {
@Value("${jdbc.url}")
private String url;
@Value("${jdbc.username}")
private String username;
@Value("${jdbc.password}")
private String password;
@Bean
public DataSource dataSource() {
HikariDataSource dataSource = new HikariDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setJdbcUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setMaximumPoolSize(10);
return dataSource;
}
@Bean
public Sql2o sql2o() {
return new Sql2o(dataSource());
}
}