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

3-7配置jdbcTempalte多数据源里的配置文件两个jdbcTemplate对象不会覆盖吗 #87

Closed
hhf296095496 opened this issue May 24, 2022 · 7 comments

Comments

@hhf296095496
Copy link

@bean
public JdbcTemplate primaryJdbcTemplate(@qualifier("primaryDataSource") DataSource primaryDataSource) {
return new JdbcTemplate(primaryDataSource);
}

@Bean
public JdbcTemplate secondaryJdbcTemplate(@Qualifier("secondaryDataSource") DataSource secondaryDataSource) {
    return new JdbcTemplate(secondaryDataSource);
}

上面是配置文件里的代码,这样写不会覆盖吗,容器里毕竟只能有一个JdbcTemplate类型的对象

@xiaofeiahaha
Copy link

xiaofeiahaha commented May 24, 2022 via email

@liuhamglin
Copy link

liuhamglin commented May 24, 2022 via email

@uncleCG
Copy link

uncleCG commented May 24, 2022 via email

@dyc87112
Copy link
Owner

不会覆盖,这两个@bean名称不同,会默认取方法名来命名,一个是primaryJdbcTemplate,一个是secondaryJdbcTemplate

@uncleCG
Copy link

uncleCG commented Oct 11, 2022 via email

@xiaofeiahaha
Copy link

xiaofeiahaha commented Oct 11, 2022 via email

@liuhamglin
Copy link

liuhamglin commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants