我正在使用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的配置变化吗?
2条答案
按热度按时间c9x0cxw01#
MySQL是一个关系数据库,MongoDB是一个文档数据库。
Hibernate支持OGM(对象/网格Map器)形式的NOSQL数据库,OGM http://docs.jboss.org/hibernate/ogm/4.2/reference/en-US/html/上的文档
有关Spring、Hibernate和MongoDB https://pragmaticintegrator.wordpress.com/2011/07/14/use-spring-and-hibernate-with-mongodb/,请参考以下示例
此外,如果你使用的是Spring,如果你想删除Hibernate,你可以去Spring MongoTemplate参考下面url https://spring.io/guides/gs/accessing-data-mongodb/中的示例
lyr7nygr2#
OR数量