国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

mongodb - spring-data-mongo 該如何連接到其他的庫(kù) 而不是默認(rèn)的test庫(kù)?
phpcn_u1582
phpcn_u1582 2017-05-02 09:18:40
0
1
604

我現(xiàn)在通過spring-boot + spring-mongo 做一個(gè)小demo ,都是最新版本 , 現(xiàn)在出現(xiàn)了一個(gè)問題就是無論如何都不能連接到其他的庫(kù) ,只能連接到mongodb默認(rèn)的test庫(kù) , 是什么原因 ?

配置 application.yml:

spring.data.mongodb.uri: mongodb://localhost:27017/mongo

按理說這里應(yīng)該連接到mongo庫(kù)才對(duì) 。我的mongodb沒有配置權(quán)限驗(yàn)證,及不需要密碼和用戶名

gradle :

   compile("org.springframework.boot:spring-boot-starter-data-mongodb")
   compile("org.springframework.boot:spring-boot-starter-web")

entity :

@Document(collection="customer")
public class Customer {

    @Id
    private String id;

    private String firstName;
    private String lastName;

repository :

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

controller :

    //http://localhost:8080/id
    @RequestMapping("/{id}")
    public Object getmongodbID(@PathVariable String id){
       return customerRepository.getIdCustomer(id);
    }

然后訪問拿到的內(nèi)容是test庫(kù)里面的 , 到底怎么回事 ?

phpcn_u1582
phpcn_u1582

reply all(1)
洪濤

Add configuration to your application.yml or prop file
data:

mongodb:
  database: tara
  host: localhost
  port: 27017
  username: tara
  password: tara
  authentication-database: tara
  repositories:
    enabled: true
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template