![](/img/trans.png)
[英]I am reciving a bean creation error with my security config class for spring security
[英]I want to access my Session variable during my bean creation time
我想在spring啟動時在bean創建期間使用會話變量,我的代碼是這樣的。
@Configuration公共類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);
}}
請寫下這樣的內容: 在此處輸入鏈接描述
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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.