Change datasource configuration and remove driver class from properties.
This commit is contained in:
parent
5965836486
commit
91f512b1e2
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.developers.configuration;
|
package eu.dnetlib.developers.configuration;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||||
|
@ -19,11 +20,9 @@ public class DataSourceConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
return DataSourceBuilder.create()
|
||||||
dataSource.setDriverClassName(this.datasource.getDriver());
|
.url(this.datasource.getUrl())
|
||||||
dataSource.setUrl(this.datasource.getUrl());
|
.username(this.datasource.getUsername())
|
||||||
dataSource.setUsername(this.datasource.getUsername());
|
.password(this.datasource.getPassword()).build();
|
||||||
dataSource.setPassword(this.datasource.getPassword());
|
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.dnetlib.developers.configuration;
|
package eu.dnetlib.developers.configuration;
|
||||||
|
|
||||||
public class Datasource {
|
public class Datasource {
|
||||||
private String driver;
|
|
||||||
private String url;
|
private String url;
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
|
@ -9,14 +8,6 @@ public class Datasource {
|
||||||
public Datasource() {
|
public Datasource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDriver() {
|
|
||||||
return driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDriver(String driver) {
|
|
||||||
this.driver = driver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,7 @@ public class DeployService {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void checkProperties() {
|
public void checkProperties() {
|
||||||
if (properties.getDatasource().getDriver() == null || properties.getDatasource().getDriver().isEmpty()) {
|
if (properties.getDatasource().getUrl() == null || properties.getDatasource().getUrl().isEmpty()) {
|
||||||
throw new RuntimeException("developers.datasource.driver is missing!");
|
|
||||||
} else if (properties.getDatasource().getUrl() == null || properties.getDatasource().getUrl().isEmpty()) {
|
|
||||||
throw new RuntimeException("developers.datasource.url is missing!");
|
throw new RuntimeException("developers.datasource.url is missing!");
|
||||||
} else if (properties.getIssuer() == null || properties.getIssuer().isEmpty()) {
|
} else if (properties.getIssuer() == null || properties.getIssuer().isEmpty()) {
|
||||||
throw new RuntimeException("developers.issuer is missing!");
|
throw new RuntimeException("developers.issuer is missing!");
|
||||||
|
@ -33,7 +31,6 @@ public class DeployService {
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
Map<String, String> response = new HashMap<>();
|
Map<String, String> response = new HashMap<>();
|
||||||
response.put("developers.datasource.driver", properties.getDatasource().getDriver());
|
|
||||||
response.put("developers.datasource.url", properties.getDatasource().getUrl());
|
response.put("developers.datasource.url", properties.getDatasource().getUrl());
|
||||||
response.put("developers.datasource.username", properties.getDatasource().getUsername());
|
response.put("developers.datasource.username", properties.getDatasource().getUsername());
|
||||||
response.put("developers.datasource.password", properties.getDatasource().getPassword());
|
response.put("developers.datasource.password", properties.getDatasource().getPassword());
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
developers.datasource.driver=org.postgresql.Driver
|
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
|
||||||
|
|
||||||
## API Documentation Properties
|
## API Documentation Properties
|
||||||
api.title = Developers API
|
api.title = Developers API
|
||||||
api.description = Developers API includes authentication methods and provides functionalities to manage OpenAIRE Dynamic AAI APIs.
|
api.description = Developers API includes authentication methods and provides functionalities to manage OpenAIRE Dynamic AAI APIs.
|
||||||
|
|
Loading…
Reference in New Issue