fixed gitiignore config dir issue

This commit is contained in:
Rohan Sircar 2020-01-22 18:49:24 +05:30
parent 28fb663d55
commit 6facac20cf
2 changed files with 48 additions and 1 deletions

2
chatto/.gitignore vendored
View File

@ -32,7 +32,7 @@ build/
../vscode/
node_modules
config/
/config/
bundle.js
bundle.min.js
src/main/javascript/node/

View File

@ -0,0 +1,47 @@
package org.ros.chatto.config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Configuration
@Component
// @ConfigurationProperties(prefix = "chatto.datasource")
@Getter
@Setter
@Slf4j
public class DataSourceConfig {
// jdbc:mysql://localhost:3306/chatto_db?useSSL=false
private final String DATASOURCE_URL = "jdbc:mysql://localhost:3306/%s?useSSL=false";
private final String username;
private final String password;
private final String databaseName;
public DataSourceConfig(@Value("${chatto.datasource.username}") String username,
@Value("${chatto.datasource.password}") String password,
@Value("${chatto.datasource.database-name}") String databaseName) {
this.username = username;
this.password = password;
this.databaseName = databaseName;
}
@Bean
public DataSource getDataSource() {
final DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.url(String.format(DATASOURCE_URL, databaseName));
dataSourceBuilder.username(username);
dataSourceBuilder.password(password);
return dataSourceBuilder.build();
}
}