Spring-Session Grails插件(第2部分)

Fork me on GitHub

In my previous blog I’ve explained spring-session grails plugin along with Redis datastore. We’ve also covered JSON serialization that will be almost same when you use mongo datastore. In this blog post I’ll explain how you can use MongoDB as your session store.

要更改数据存储区,您需要在配置槽。

springsession.sessionStore=SessionStore.MONGO

这会将MongoDB设置为您的数据存储。 默认情况下,它将尝试连接正在运行的mongo本地主机港口27017。 我们来看看一些配置属性及其默认值。

注意:Someofthecommonpropertiesexplainedinpreviousblock。Thosewillworksameformongodatastore。

springsession.mongo.hostName="localhost" // MongoDB host server. Default is localhost.
springsession.mongo.port=27017 // MongoDB port. Default is 27017.
springsession.mongo.database="spring-session" // MongoDB database to store sessions. Default is spring-session.
springsession.mongo.username="" // MongoDB username. Default is "".
springsession.mongo.password="" // MongoDB password. Default is "".
springsession.mongo.collectionName="sessions" // Mongo collection name to store session data. Default is "sessions".
springsession.mongo.replicaSet=[[:] ] // MongoDB replica set if any. It includes list of maps [[hostName: 'localhost', port: 27017] ] Default is [[:]].
springsession.mongo.jackson.modules=[] // Jackson module class if any. Default is empty list

注意:MongoDBisaNoSQLandschemalessdatabase.Soyoudon’tneedtocreatedatabaseandcollectionsforthesession.It’llautocreatedwhensessionwillcreated.

By default it uses Java serialization. To use JSON Serialization please visit to first blog of this series. First 2 steps will be same but in 3rd step Register my module class with spring-session plugin you will have to use mongo specific jackson.modules property.

springsession.mongo.jackson.modules = ['demo.SimpleModule']

就是这个帖子。 在下一个博客中,我将说明如何将JDBC数据存储区与spring-session grails插件一起使用。

from: https://dev.to//jeetmp3/spring-session-grails-plugin-part-2-j3l

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值