我正在使用MOXy的JAXB实现和外部元数据绑定文件来面对涉及继承和多态的编组/解组问题.
我无法控制XML文件或模型类.
模型中有多个继承其他DTO类的类.以下是我正在使用的环境示例.此示例仅用于某些语法目的,真实环境涉及嵌套继承,集合等.
这是将继承的类
class A {
private String name;
public String getName(){
return name;
}
public void setName(String value){
name = value;
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个继承的类
class B extends A {
private String attrFromB;
public String getAttrFromB(){
return attrFromB;
}
public void setAttrFromB(String value){
attrFromB = value;
}
}
Run Code Online (Sandbox Code Playgroud)
而另一个
class C extends A {
private String attrFromC;
public String getAttrFromC(){
return attrFromC;
}
public void setAttrFromC(String value){
attrFromC= value;
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个容器类
class MyContainerClass{
private A myObject;
public A …Run Code Online (Sandbox Code Playgroud) 我一般都是MOXy和JaxB的新手,我遇到了java.util.Date转换的问题.
我正在使用映射文件将XML文件(我无法控制)解组为对象(我既不能手动注释现有类也不能更改它们).
我的XML映射文件如下所示:
<?xml version="1.0"?>
<xml-bindings
xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
version="2.1">
<java-types>
<java-type name="Observation">
<xml-type prop-order="date theoricalTime ci ch cr type" />
<java-attributes>
<xml-element java-attribute="date" xml-path="Date/text()" />
<xml-element java-attribute="theoricalTime" xml-path="TheoricalTime/text()" />
<xml-element java-attribute="ci" xml-path="CIPR/text()" />
<xml-element java-attribute="ch" xml-path="CHPR/text()" />
<xml-element java-attribute="cr" xml-path="CRPR/text()" />
<xml-element java-attribute="type" xml-path="Type/text()" />
</java-attributes>
</java-type>
</java-types>
</xml-bindings>
Run Code Online (Sandbox Code Playgroud)
在我正在编组的类中,属性"date"和"theoricalTime"的类型为java.util.Date.
从我是从编组XML中的值是用这种格式的字符串:"DD/MM/YYYY HH:MM:SS"("2012/05/01 16时36分24秒").我也有一些只有时间值"HH:mm:ss"("14:17:33")的字段.
这是我在解组文件时得到的堆栈跟踪:
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-3002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ConversionException
Exception Description: The object [22/01/2009 20:56:29], of class [class java.lang.String], from mapping …Run Code Online (Sandbox Code Playgroud) 我正在构建一个部署在CentOS 7.2上的ASP.Net Core(netcore 1.1)应用程序.
我有一个动作通过System.Diagnostics.Process调用外部进程(也是使用.net内核构建的控制台应用程序),并且在返回之前不等待它退出.
问题在于,<defunct>即使在完成执行之后,所述过程也会变为并保持不变.我不想等它退出,因为这个过程可能需要几分钟才能完成.
这是一个示例代码
//The process is writing its progress to a sqlite database using a
//previously generated guid which is used later in order to check
//the task's progress
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "/bin/sh -c \"/path/to/process/executable -args\"";
psi.UseShellExecute = true;
psi.WorkingDirectory = "/path/to/process/";
psi.RedirectStandardOutput = false;
psi.RedirectStandardError = false;
psi.RedirectStandardInput = false;
using(Process proc = new Process({ StartInfo = psi }))
{
proc.Start();
}
Run Code Online (Sandbox Code Playgroud)
该过程开始并完成其工作.它将其特定任务的进度写入sqlite数据库.然后,我可以探测该数据库以查看进度.
一切运行正常,但我可以看到ps -ef |grep executable它被列为流程执行后,它 …