From 035036a1c295850c5ae143eab6d350ac2f3e346a Mon Sep 17 00:00:00 2001 From: qnfn120 <101265039+genius00hwan@users.noreply.github.com> Date: Wed, 27 Nov 2024 15:13:14 +0900 Subject: [PATCH] =?UTF-8?q?hotfix=20:=20mongoDB=20atlas=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config | 2 +- .../service/AdminCurriculumService.java | 1 + .../global/config/SSHMongoConfig.java | 24 ++++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config b/config index 9b0654f..b9b8ab7 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 9b0654fef81b7f0d149242e17e28b1d776e4df67 +Subproject commit b9b8ab7883e56c0c1982030261262f612f2f1b6e diff --git a/src/main/java/icurriculum/domain/curriculum/service/AdminCurriculumService.java b/src/main/java/icurriculum/domain/curriculum/service/AdminCurriculumService.java index f912b81..9e627d7 100644 --- a/src/main/java/icurriculum/domain/curriculum/service/AdminCurriculumService.java +++ b/src/main/java/icurriculum/domain/curriculum/service/AdminCurriculumService.java @@ -30,6 +30,7 @@ public Curriculum getCurriculum( ) { CurriculumDecider decider = convertToDecider(majorType, departmentName, joinYear); + return repository.findByDecider(decider) .orElseThrow(() -> new GeneralException(ErrorStatus.CURRICULUM_NOT_FOUND)); } diff --git a/src/main/java/icurriculum/global/config/SSHMongoConfig.java b/src/main/java/icurriculum/global/config/SSHMongoConfig.java index 29d52f5..ca4de50 100644 --- a/src/main/java/icurriculum/global/config/SSHMongoConfig.java +++ b/src/main/java/icurriculum/global/config/SSHMongoConfig.java @@ -38,33 +38,39 @@ public class SSHMongoConfig { @Value("${spring.data.mongodb.database}") private String databaseName; + @Value("${spring.data.mongodb.connection_string}") + private String connectionCommand; + + @Value("${spring.data.mongodb.app_name") + private String appName; + @Bean public MongoClient mongoClient() { String host = databaseEndpoint; int port = databasePort; // if (isServer.equals("false")) { - log.info("isServer value: {}", isServer); - Integer forwardedPort = initializer.buildSshConnection(databaseEndpoint, databasePort); - host = "localhost"; - port = forwardedPort; +// log.info("isServer value: {}", isServer); +// Integer forwardedPort = initializer.buildSshConnection(databaseEndpoint, databasePort); +// host = "localhost"; +// port = forwardedPort; // } try { ConnectionString connectionString = new ConnectionString(String.format( - "mongodb://%s:%s@%s:%s/%s?readPreference=secondaryPreferred&retryWrites=false", + connectionCommand, mongoUser, mongoPassword, - host, - port, - databaseName + databaseEndpoint, + databaseName, + appName )); MongoClientSettings mongoClientSettings = MongoClientSettings.builder() .applyConnectionString(connectionString) .build(); - log.info("mongo connection through SSH: host={}, port={}", host, port); + log.info("mongo connection through SVG: end_point={}", databaseEndpoint); return MongoClients.create(mongoClientSettings); } catch (Exception e) {