Skip to content

Commit

Permalink
Merge branch 'feature/fleming' into feature/eds-revolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincenzo Ingenito authored and Vincenzo Ingenito committed Oct 2, 2023
2 parents 40c949c + d7bae4b commit 2bd1a26
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;

import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClients;

import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.mongo.MongoLockProvider;

Expand All @@ -45,7 +49,11 @@ public class MongoDatabaseCFG {
*/
@Bean
public MongoDatabaseFactory createFactory(MongoPropertiesCFG props) {
return new SimpleMongoClientDatabaseFactory(props.getUri());
ConnectionString connectionString = new ConnectionString(props.getUri());
MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
.applyConnectionString(connectionString)
.build();
return new SimpleMongoClientDatabaseFactory(MongoClients.create(mongoClientSettings), props.getSchemaName());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,23 @@
*/
package it.finanze.sanita.fse2.ms.gtw.rulesmanager.config.mongo;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import lombok.Data;


/**
*
* Mongo properties configuration.
*/
@Data
@Component
@EqualsAndHashCode(callSuper = false)
public class MongoPropertiesCFG implements Serializable {
public class MongoPropertiesCFG {

/**
* Serial version uid
*/
private static final long serialVersionUID = -7936473659737067416L;

@Value("${data.mongodb.uri}")
private String uri;

@Value("${data.mongodb.schema-name}")
private String schemaName;
}
2 changes: 1 addition & 1 deletion src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ management.server.port=8011

### MONGODB ###
data.mongodb.uri=mongodb://mongoadmin:secret@localhost:27888/fse

data.mongodb.schema-name=FSE_GTW
### EDS CLIENT (REST) ###
eds.rest.secured=false

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ kafka.enablessl=true

### MONGODB ###
data.mongodb.uri=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@<mondodb_hostname>:<mondodb_port>/<mondodb_dbname>
data.mongodb.schema-name=${MONGO_DBNAME}

### EDS CLIENT (REST) ###
eds.rest.kspwd=
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### MONGODB ###
data.mongodb.uri=mongodb://mongoadmin:secret@localhost:27888/fse

data.mongodb.schema-name=FSE_GTW
### REDIS ###
redis.hostname=localhost
redis.port=6379
Expand Down

0 comments on commit 2bd1a26

Please sign in to comment.