【发布时间】:2016-09-03 15:16:34
【问题描述】:
我正在使用 spring 数据来存储和从数据库中获取记录。最初数据库是 MySQL,但现在我想为 mongodb 配置相同的应用程序。请查看 MySQL 的应用程序资源属性。
# ===============================
# = DATA SOURCE
# ===============================
# Connection url for the database connection
spring.datasource.url = jdbc:mysql://localhost:27017/purchase_books
# Username and password
spring.datasource.username = root
spring.datasource.password = root
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle = true
spring.datasource.validationQuery = SELECT 1
# ===============================
# = JPA / HIBERNATE
# ===============================
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in the project
spring.jpa.hibernate.ddl-auto = update
# Naming strategy
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
谁能告诉mongodb的配置变化?
【问题讨论】:
-
在他们的网站上有一个很好的关于 Spring Data for MongoDb 的文档。
标签: mongodb spring-data