FINALLY FIXED DATABASE ACCESS OH MY FUCKING I'M EXHAUSTED
This commit is contained in:
@@ -2,9 +2,11 @@ package be.naaturel.boardmateapi.configurations;
|
||||
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
@Configuration
|
||||
public class MongoConfig {
|
||||
@@ -17,7 +19,10 @@ public class MongoConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoClient mongoClient() {
|
||||
return MongoClients.create(this.conf.connectionString);
|
||||
public MongoTemplate mongoTemplate() {
|
||||
System.out.println(">>> Connection string : " + conf.connectionString);
|
||||
System.out.println(">>> Used database : " + conf.database);
|
||||
MongoClient client = MongoClients.create(this.conf.connectionString);
|
||||
return new MongoTemplate(client, conf.database);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package be.naaturel.boardmateapi.configurations;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class Startup {
|
||||
|
||||
AppConfigurations conf;
|
||||
|
||||
@Autowired
|
||||
public Startup(AppConfigurations appConf) {
|
||||
this.conf = appConf;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String log(){
|
||||
System.out.println(">>> Connection string : " + conf.connectionString);
|
||||
System.out.println(">>> Database : " + conf.database);
|
||||
return "logged";
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,12 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
public class PartyController {
|
||||
public class GameController {
|
||||
|
||||
private final GameService service;
|
||||
|
||||
@Autowired
|
||||
public PartyController(GameService service){
|
||||
public GameController(GameService service){
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,10 @@ public class PartyController {
|
||||
.status(HttpStatus.OK)
|
||||
.body(g);
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
e.printStackTrace();
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +54,10 @@ public class PartyController {
|
||||
status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.build();
|
||||
} catch (Exception e){
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
e.printStackTrace();
|
||||
return ResponseEntity
|
||||
.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body(e.getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,5 @@ springdoc.swagger-ui.path=/api-docs
|
||||
springdoc.api-docs.path=/v1/api-docs
|
||||
|
||||
#=============DATABASE=============
|
||||
spring.data.mongodb.uri=mongodb://board-mate-user:apx820kcng@mongodb:27017/board-mate-db
|
||||
spring.data.mongodb.database=board-mate-db
|
||||
spring.data.mongodb.uri=mongodb://board-mate-user:apx820kcng@mongodb:27017/board-mate-db?authSource=board-mate-db
|
||||
spring.data.mongodb.database=board-mate-db
|
||||
|
||||
Reference in New Issue
Block a user