Skip to content

Commit

Permalink
fix: mongo configuration null
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed May 11, 2022
1 parent cdb9eb1 commit a8c44c0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.insee.knowledge</groupId>
<artifactId>knowledge</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<packaging>jar</packaging>
<name>Knowledge-Back-Office</name>
<description>Back-office services for Knowledge</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoDatabase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -21,9 +23,12 @@ public class MongoConfiguration {
@Value("${mongodb.host}")
private String host;

private final String mongoUri = String.format("mongodb://%s:%s@%s:27017/%s?authSource=%s", username, password, host, database, database);
private final static Logger LOGGER = LoggerFactory.getLogger(MongoConfiguration.class);


private MongoClient mongoClient() {
String mongoUri = String.format("mongodb://%s:%s@%s:27017/%s?authSource=%s", username, password, host, database, database);
LOGGER.info(String.format("MongoURI : %s", mongoUri));
return MongoClients.create(mongoUri);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void handleContextRefresh(ContextRefreshedEvent event) {
.flatMap(Arrays::stream)
.distinct()
.filter(prop -> !(prop.contains("credentials") || prop.contains("password")))
.sorted()
.forEach(prop -> LOGGER.info("{}: {}", prop, env.getProperty(prop)));
LOGGER.info("===========================================");
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ spring.profiles.active=dev
#Cors
fr.insee.knowledge.application.crosOrigin=*
#MongoDB
mongodb.database=
mongodb.host=
mongodb.username=
mongodb.password=
mongodb.database=database
mongodb.host=host
mongodb.username=username
mongodb.password=password
#Repository Github Data
fr.insee.knowledge.git.access.rawrepository=https://raw.githubusercontent.com/ddecrulle/Knowledge-Data/main/

0 comments on commit a8c44c0

Please sign in to comment.