fixed gitiignore config dir issue
This commit is contained in:
parent
28fb663d55
commit
6facac20cf
2
chatto/.gitignore
vendored
2
chatto/.gitignore
vendored
@ -32,7 +32,7 @@ build/
|
|||||||
../vscode/
|
../vscode/
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
config/
|
/config/
|
||||||
bundle.js
|
bundle.js
|
||||||
bundle.min.js
|
bundle.min.js
|
||||||
src/main/javascript/node/
|
src/main/javascript/node/
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user