diff --git a/src/main/java/com/uniovi/services/QuestionGeneratorService.java b/src/main/java/com/uniovi/services/QuestionGeneratorService.java index d4e3532..3a80024 100644 --- a/src/main/java/com/uniovi/services/QuestionGeneratorService.java +++ b/src/main/java/com/uniovi/services/QuestionGeneratorService.java @@ -16,6 +16,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -31,7 +33,7 @@ public class QuestionGeneratorService { private final QuestionService questionService; - public static final String JSON_FILE_PATH = "src/main/resources/static/JSON/QuestionTemplates.json"; + public static final String JSON_FILE_PATH = "static/JSON/QuestionTemplates.json"; private Deque types = new ArrayDeque<>(); @@ -52,9 +54,9 @@ public QuestionGeneratorService(QuestionService questionService, Environment env } private void parseQuestionTypes() throws IOException { - File jsonFile = new File(JSON_FILE_PATH); + Resource resource = new ClassPathResource(JSON_FILE_PATH); ObjectMapper objectMapper = new ObjectMapper(); - json = objectMapper.readTree(jsonFile); + json = objectMapper.readTree(resource.getInputStream()); JsonNode categories = json.findValue("categories"); for (JsonNode category : categories) { String categoryName = category.get("name").textValue();