i want to use session variable during bean creation time in spring boot and my code is something like this.
@Configuration public class DataSourceConfig {
String dbName;
@Bean(name = "jMaster")
@Autowired
public JdbcTemplate masterTemplate(@Qualifier("dsMaster") DataSource dsMaster) {
this.dbName=// i want here to take value from session ;
return new JdbcTemplate(dsMaster);
} }
Please write something like this: enter link description here
return DataSourceBuilder
.create()
.username(env.getProperty("app.datasource.username"))
.password(env.getProperty("app.datasource.password"))
.url(env.getProperty("your URL to database"))
.driverClassName(env.getProperty("app.datasource.driverClassName"))
.build();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.