首页 \ 问答 \ 将LocalDateTime映射到Instant(Mapstruct LocalDateTime to Instant)

将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 includes Instant type field. I want to map LocalDateTime type field to Instant 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
更新时间:2023-07-24 22:07

最满意答案

您收到的错误表明数据仍然存在,但是当它映射数据文件时,某些内容会导致问题。 这条线是你需要看的第一件事情:

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(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 ...
  • 这一行: 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数据,很难给出明确的答案,但是当您的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是否正在您的机器上运行( 默认情况下,它将在端口27017上运行 )? 尝试从mongo shell插入一些示例数据。 示例命令: use testDB db.testCollection.insert({"name":"dev"}); 它将在testDB数据库的testCollection中插入这些数据。 您可以使用以下方式找到它 db.testCollection.find() ...
  • 您可以尝试使用以下选项运行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: { ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。