Spring Boot中使用MongoDB

2019-04-14 Yazzyk

pom文件中

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>
</dependencies>

application.properties中

##mongo配置
spring.data.mongodb.host=127.0.0.1
spring.data.mongodb.port=27017
spring.data.mongodb.database=test

主类中

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)