如何将包注释从 java 转换为 scala
我按照这里的教程
http:// blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html
将 joda DateTime 与球衣一起使用。但我是在 scala 中完成的,当需要将以下代码片段从 java 转换为 scala 时,我完全不知所措。有人可以帮助我或给我一些教程的链接吗?
@XmlJavaTypeAdapters({
@XmlJavaTypeAdapter(type=DateTime.class,
value=DateTimeAdapter.class),
@XmlJavaTypeAdapter(type=DateMidnight.class,
value=DateMidnightAdapter.class),
@XmlJavaTypeAdapter(type=LocalDate.class,
value=LocalDateAdapter.class),
@XmlJavaTypeAdapter(type=LocalTime.class,
value=LocalTimeAdapter.class),
@XmlJavaTypeAdapter(type=LocalDateTime.class,
value=LocalDateTimeAdapter.class)
})
package blog.jodatime;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.joda.time.DateMidnight;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
我应该使用包注释,我不知道它是如何完成的,而且谷歌不是我的朋友。
I follow the tutorial here
http://blog.bdoughan.com/2011/05/jaxb-and-joda-time-dates-and-times.html
to use joda DateTime with jersey. But I am doing it in scala and I am completely at a lost when it come to translate the following snippet of code from java to scala. Can anybody help me or give me link to some tutorial?
@XmlJavaTypeAdapters({
@XmlJavaTypeAdapter(type=DateTime.class,
value=DateTimeAdapter.class),
@XmlJavaTypeAdapter(type=DateMidnight.class,
value=DateMidnightAdapter.class),
@XmlJavaTypeAdapter(type=LocalDate.class,
value=LocalDateAdapter.class),
@XmlJavaTypeAdapter(type=LocalTime.class,
value=LocalTimeAdapter.class),
@XmlJavaTypeAdapter(type=LocalDateTime.class,
value=LocalDateTimeAdapter.class)
})
package blog.jodatime;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.joda.time.DateMidnight;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
I am supposed to use a package annotation, I have no idea how its done, and Google isn't my friend.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,Scala 不支持包注释: https://issues.scala-lang .org/browse/SI-3600。但是你不能将这些注释放在 package-info.java 文件中吗?
Package annotations are not supported in Scala for all I know: https://issues.scala-lang.org/browse/SI-3600. But can't you put these annotations in package-info.java file?