简体   繁体   中英

I want to access my Session variable during my bean creation time

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM