Answer the question
In order to leave comments, you need to log in
How to initialize a database in Spring JPA based on data from a read file?
During the launch of my application, I have such important data as url, username, password for connecting to the database (DataSource) read from some configuration file.
I don't know how to initialize a Bean DataSource with this data if it has nothing to do with JavaConfig.
I have javaconfig
@Configuration
public class JavaConfig {
@Bean
public DataSource dataSource() {
return new MysqlDataSource();
}
/* etc code */
}
public class SQLBase {
public static void initDataSource() {
/* reading data */
??.setUrl(url);
??.setUsername(username);
??.setPassword(password);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question