Change Datasource configuration and remove driver class property.

This commit is contained in:
Konstantinos Triantafyllou 2024-11-01 13:50:03 +02:00
parent 97902d2019
commit d20db9b8d8
4 changed files with 6 additions and 23 deletions

View File

@ -1,9 +1,9 @@
package eu.dnetlib.uoausermanagment.configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import javax.sql.DataSource;
@ -19,11 +19,9 @@ public class DataSourceConfig {
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(this.datasource.getDriver());
dataSource.setUrl(this.datasource.getUrl());
dataSource.setUsername(this.datasource.getUsername());
dataSource.setPassword(this.datasource.getPassword());
return dataSource;
return DataSourceBuilder.create()
.url(this.datasource.getUrl())
.username(this.datasource.getUsername())
.password(this.datasource.getPassword()).build();
}
}

View File

@ -1,7 +1,6 @@
package eu.dnetlib.uoausermanagment.configuration;
public class Datasource {
private String driver;
private String url;
private String username;
private String password;
@ -9,14 +8,6 @@ public class Datasource {
public Datasource() {
}
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUrl() {
return url;
}

View File

@ -43,9 +43,7 @@ public class DeployService {
if(!profiles.contains("html") && !profiles.contains("registry")) {
throw new RuntimeException("You need to specify at least one profile (html, registry)");
}
if (datasource.getDriver() == null || datasource.getDriver().isEmpty()) {
throw new RuntimeException("user-management.datasource.driver is missing!");
} else if (datasource.getUrl() == null || datasource.getUrl().isEmpty()) {
if (datasource.getUrl() == null || datasource.getUrl().isEmpty()) {
throw new RuntimeException("user-management.datasource.url is missing!");
} else if (mail.getHost() == null || mail.getHost().isEmpty()) {
throw new RuntimeException("user-management.mail.host is missing!");
@ -102,7 +100,6 @@ public class DeployService {
response.put("user-management.developers", developers);
response.put("user-management.developers-api", developersApi);
response.put("user-management.login-url", loginUrl);
response.put("user-management.datasource.driver", datasource.getDriver());
response.put("user-management.datasource.url", datasource.getUrl());
response.put("user-management.datasource.username", datasource.getUsername());
response.put("user-management.datasource.password", datasource.getPassword());

View File

@ -1,6 +1,3 @@
api.title = Uoa User Management
api.description = Uoa User Management is a service which communicates with Role Management and provides method to invite userDetails to be members or managers of an OpenAIRE entity.
api.version = ${project.version}
user-management.datasource.driver=org.postgresql.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect