将LocalDateTime映射到Instant(Mapstruct LocalDateTime to Instant)
我是Mapstruct的新手。 我有一个包含
LocalDateTime
类型字段的模型对象。 DTO包括Instant
类型字段。 我想将LocalDateTime
类型字段映射到Instant
类型字段。 我有传入请求的TimeZone实例。像那样手动设置场地;
set( LocalDateTime.ofInstant(x.getStartDate(), timeZone.toZoneId()) )
我如何使用Mapstruct来映射这些字段?
I am new in Mapstruct. I have a model object which includes
LocalDateTime
type field. DTO includesInstant
type field. I want to mapLocalDateTime
type field toInstant
type field. I have TimeZone instance of incoming requests.Manually field setting like that;
set( LocalDateTime.ofInstant(x.getStartDate(), timeZone.toZoneId()) )
How can I map these fields using with Mapstruct?
原文:https://stackoverflow.com/questions/47901178
最满意答案
您收到的错误表明数据仍然存在,但是当它映射数据文件时,某些内容会导致问题。 这条线是你需要看的第一件事情:
Thu Jul 26 12:05:44 [conn5] Assertion: 13636:file /var/lib/mongodb/baza.4 open/create failed in createPrivateMap (look in log for more information)
检查该文件(以及数据路径中的其他文件)的权限,确保从该角度看没有任何问题。
接下来,出现内存不足错误:
Thu Jul 26 12:05:44 [conn5]错误:mmap专用失败,内存不足。 (64位版本)
您可能会遇到此错误: https : //jira.mongodb.org/browse/SERVER-6414
因此,您可以尝试2.0.7,其中包含对此的修复,发布候选版本可以在下载页面上找到,就像写这篇文章一样。
最后,如果你有选择,你可以通过在这个实例中增加内存来解决这个问题(如果它是某种虚拟机的话)1.4GB在运行MongoDB实例方面并不是很多RAM。
The error you are getting suggests that the data is still there, but something is causing a problem when it mmaps the data files. This line is the first thing you need to look at:
Thu Jul 26 12:05:44 [conn5] Assertion: 13636:file /var/lib/mongodb/baza.4 open/create failed in createPrivateMap (look in log for more information)
Check the permissions on that file (and other files in the data path), make sure nothing is wrong from that perspective.
Next, there is the out of memory error:
Thu Jul 26 12:05:44 [conn5] ERROR: mmap private failed with out of memory. (64 bit build)
You might be running into this bug: https://jira.mongodb.org/browse/SERVER-6414
So, you can try 2.0.7 which contains a fix for this, the release candidate is available on the downloads page as of writing this.
Finally, if you have the option you may be able to solve this by increasing memory on this instance (if it is a virtual machine of some sort) 1.4GB is not a lot of RAM in terms of running a MongoDB instance.
相关问答
更多-
MongoDB数据库消失了(MongoDB databases disappeared)[2022-04-14]
在手动重启时,看起来您正在运行具有所有默认值的mongodb(dbpath是/ data / db,而原始ulimit错误是记录/ usr / local / var / mongodb)。 哪条路径应该是正确的? 如果您使用错误的dbpath手动运行它,您将看到一个空数据库。 然后,如果你没有干净地停止这个过程(例如kill-9),那可能已经破坏了这个实例(希望在一个不正确的dbpath上)。 首先,获取/ usr / local / var / mongodb路径的副本。 然后尝试使用正确的dbpath ... -
您收到的错误表明数据仍然存在,但是当它映射数据文件时,某些内容会导致问题。 这条线是你需要看的第一件事情: Thu Jul 26 12:05:44 [conn5] Assertion: 13636:file /var/lib/mongodb/baza.4 open/create failed in createPrivateMap (look in log for more information) 检查该文件(以及数据路径中的其他文件)的权限,确保从该角度看没有任何问题。 接下来,出现内存不足错误: T ...
-
Mongodb没有创建数据库(Mongodb not creating database)[2023-10-27]
这一行: As soon as you create a record with that connection 从这个回答: 是否可以使用Mongoose在MongoDB中创建一个新数据库? 对我来说。 在我的情况下,我不得不手动: 创建数据库 创建一个集合 在集合中创建记录 然后一切都很好。 It seems that my mongodb was not locked properly so i remove the mongodb.lock file and run with -repair op ... -
此命令将适用于您如果您的dbpath已设置或您mongoDB服务正在运行此ihtx表示您的dbname $ mongodump -d ihtx --out /home/user/Desktop/intxDB This command will work for you If your dbpath is set or you mongoDB service is Running here ihtx denotes your dbname $ mongodump -d ihtx --out /home/us ...
-
经过一番混乱后,我发现解决方案是: 更改数据库所在文件夹的权限。 更改mongodb.conf路径变量 使用mongod --dbpath /media/meaniostack/OS/data/db而不是: service mongod start 希望这有助于任何有类似问题的人。 After a bit of messing around I found the solution to be: Alter permissions to the folders that the database is in ...
-
按原样运行以下命令: 在Windows中打开命令行提示符 转到你的mongodb目录(〜/ mongodb / bin /)并运行以下命令: ./mongo --bind_ip localhost:27017 现在,它将向您显示mongo服务器正在运行并在端口27017处等待连接的消息。 现在确保您保持此窗口运行并打开一个新的Windows命令行窗口并使用相同的node main.js命令运行node main.js 这应该工作。 一切似乎现在都定了! Run the following as it is: ...
-
将csv导入mongodb数据库(Import csv to mongodb database)[2023-06-11]
好吧,如果没有向我们展示您有问题的CSV数据,很难给出明确的答案,但是当您的CSV列包裹在双引号中时,通常会导致错误,其中双引号在包装文本中包含双引号,例如 C1,C2 57,"This is a double quote:"" 要解决这个问题,你必须避免使用另一个这样的双引号 C1,C2 57,"This is a double quote:""" Well without showing us your problematic CSV data it is difficult to give ... -
Mongodb数据库不会被创建(Mongodb database is not created)[2023-10-13]
有一件事我想清楚, 当你在该数据库的任何集合中插入一些数据时 , 数据库是在MongoDB中创建的。 首先,检查MongoDB是否正在您的机器上运行( 默认情况下,它将在端口27017上运行 )? 尝试从mongo shell插入一些示例数据。 示例命令: use testDB db.testCollection.insert({"name":"dev"}); 它将在testDB数据库的testCollection中插入这些数据。 您可以使用以下方式找到它 db.testCollection.find() ... -
没有数据库的MongoDB?(MongoDB without the Database?)[2022-05-16]
您可以尝试使用以下选项运行MongoDB,这有效地阻止它将数据刷新到磁盘。 当然,如果你没有足够的内存,操作系统可能会决定做到这一点。 --syncdelay 0 You could try running MongoDB with the following option, which effectively stops it from flushing data to disk. Of course, if you don't have enough RAM, the OS may decide to ... -
尝试使用authsource而不是authdb var _dbConnectionURL = 'mongodb://uname:password@LocalIpAddress:port/databasename?authsource=admin'; 或尝试在options参数中设置authdb backup({ uri: _dbConnectionURL, root: './Media/MongoDB_BK', tar: 'sample.tar', options: { ...