Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

集成多数据源后 thymelef 渲染不起作用 #2

Open
cyf0477 opened this issue Jan 15, 2020 · 2 comments
Open

集成多数据源后 thymelef 渲染不起作用 #2

cyf0477 opened this issue Jan 15, 2020 · 2 comments

Comments

@cyf0477
Copy link

cyf0477 commented Jan 15, 2020

集成多数据源后 thymelef 渲染不起作用 前台确实是返回了数据,通过js 可以打印出

@cyf0477
Copy link
Author

cyf0477 commented Jan 15, 2020

多数据源配置
`
@configuration
@MapperScan(basePackages = "com.xservice.admin.mapper/**", sqlSessionTemplateRef = "masterSqlSessionTemplate")
public class MasterDataSourceConfiguration {

@Value("${spring.datasource.master.driver-class-name}")
private String driverClassName;

@Value("${spring.datasource.master.url}")
private String url;

@Value("${spring.datasource.master.username}")
private String username;

@Value("${spring.datasource.master.password}")
private String password;

@Bean(name = "masterDataSource")
@Primary
public DataSource dataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(this.driverClassName);
    dataSource.setUrl(this.url);
    dataSource.setUsername(this.username);
    dataSource.setPassword(this.password);
    return dataSource;
}

@Bean(name = "masterSqlSessionFactory")
@Primary
public SqlSessionFactory sqlSessionFactory(@Qualifier("masterDataSource") DataSource dataSource) throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mybatis/**/*.xml"));
    return bean.getObject();
}

@Bean(name = "masterTransactionManager")
@Primary
public DataSourceTransactionManager transactionManager(@Qualifier("masterDataSource") DataSource dataSource) {
    return new DataSourceTransactionManager(dataSource);
}

@Bean(name = "masterSqlSessionTemplate")
@Primary
public SqlSessionTemplate sqlSessionTemplate(@Qualifier("masterSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
    return new SqlSessionTemplate(sqlSessionFactory);
}

}`

yml配置

datasource: master: driver-class-name: com.mysql.jdbc.Driver url: username: cswomen password: 1qaz@WSX #配置初始化连接数大小 initial-size: 10 # 最大连接数 max-active: 50 #最小连接数 min-idle: 10 #获取连接等待超时时间 max-wait: 5000 pool-prepared-statements: true #是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。 max-pool-prepared-statement-per-connection-size: 20 validation-query: SELECT 1 FROM DUAL validation-query-timeout: 20000 test-on-borrow: false #申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 test-on-return: false #归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 test-while-idle: true #建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 min-evictable-idle-time-millis: 300000 #一个连接在池中最小生存的时间,单位是毫秒 #初始化sql 设置库为utf8mb4 connection-init-sqls: - set names 'utf8mb4'

@fuce1314
Copy link
Owner

  • -GitHub只是更新,具体得在码云。或者你进群反映,md里面有qq群,记得备注

@fuce1314 fuce1314 self-assigned this Jan 21, 2020
Repository owner locked as resolved and limited conversation to collaborators Jan 21, 2020
@fuce1314 fuce1314 removed their assignment Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants