How should spring-data-mongo connect to other libraries instead of the default test library?

  mongodb, question

I am now making a small demo through spring-boot+spring-mongo, which is the latest version. Now there is a problem that I cannot connect to other libraries in any way, only mongodb’s default test library. What is the reason?

Yml: mongodb://localhost:27017/mongo

In theory, this should be connected to the mongo library. My mongodb does not have permission authentication configured and does not require a password and user name.

gradle :


entity :

 public class Customer {
 private String id;
 private String firstName;
 private String lastName;

repository :

public interface CustomerRepository extends MongoRepository<Customer, String>,QueryDslPredicateExecutor<Customer> {

controller :

 public Object getmongodbID(@PathVariable String id){
 return customerRepository.getIdCustomer(id);

Then the contents obtained from the visit are from the test library. what’s going on?

Add configuration to your application.yml or prop file

 database: tara
 host: localhost
 port: 27017
 username: tara
 password: tara
 authentication-database: tara
 enabled: true