Hi I am following this guide for creating API. I have similar code to what is in this guide. Now I am trying to create another API within the same Project with the data stored in a separate collection. But Whenever I make any API calls, it always uses the same database. I cannot figure out where the database location is configured. Can I please get help on finding out where I can configure the database connectons to my Java program? Here is my code.
@CrossOrigin(origins = "http://localhost:4200")
@RestController
@RequestMapping("/api/v1")
public class TicketController {
@Autowired
private TicketRepository ticketRepository;
@Autowired
private TicketGeneratorService ticketGeneratorService;
@GetMapping("/tickets")
@ApiOperation(value = "Retrieves all Tickets in the database")
public List<Ticket> getAllTickets() {
return ticketRepository.findAll();
}
@PostMapping("/tickets/create")
@ApiOperation(value = "Adds a Ticket to the database")
public Ticket createTicket(@Valid @RequestBody Ticket ticket) {
ticket.setId(ticketGeneratorService.generateSequence(Ticket.SEQUENCE_NAME));
return ticketRepository.save(ticket);
}
}
Here is my application.properties file
This is the code I have under my application.properties file. I do not understand how this can be incorrect. employeeDatabase is the Database I am using, and inside it I am trying to use two different collections. All the data I create and retrieve from only comes from one of the collections. How can I get access to the other collection?
# MONGODB (MongoProperties)
spring.data.mongodb.uri=mongodb://localhost:27017/employeeDatabase
employeeDatabase is the database which includes the collections that I am using.