小编cha*_*sad的帖子

将xml存储在json对象中

我需要将完整的xml文档存储为json对象的一部分.当我收到请求并尝试从json字符串创建json对象时,如下所示 -

{"content":{
"name" : "xyz",
"details":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
 <ns0:Report xmlns:ns0=\"http://www.khisko.com/triTypes\">
  <StackTrace>Job-8004 Error in [xxxxxxxxxx]
      Output data invalid&#xD;
  at com.xyz.tst.a(Unknown Source)&#xD;
      caused by: java.lang.NullPointerException&#xD;
   </StackTrace>
   <Msg>Output data invalid</Msg>
  </ns0:Report>"
 }}
Run Code Online (Sandbox Code Playgroud)

我在第一个详细信息字符处收到未终止的字符串错误.我该怎么办呢.

我正在使用org.json.JSONObject构造函数,它以java字符串作为参数并将json作为java字符串传递给上面.

谢谢

xml json storing-information

14
推荐指数
3
解决办法
3万
查看次数

graphql错误字段查询的类型对象需要子选择

在 java 应用程序中调用 GraphQL 查询时出现以下错误 -

"description": "字段 accountQuery 的帐户类型需要子选择", "validationErrorType": "SubSelectionRequired", "queryPath": [ "accountQuery" ],

这是我的架构 -

架构 { 查询:查询 }

类型查询 { accountQuery(nbr: String): 账户 }

类型帐户 {
nbr: 字符串
名称: 字符串 ...
}

我定义了 Account POJO,并且根据传递的 nbr 值在后端调用一个服务,该服务工作正常。
这是我发送的其余请求 -

{ accountQuery(nbr: "123") }

错误是由于缺少 id 字段造成的吗?如果是,我如何将“nbr”字段标记为 id ?

java graphql

6
推荐指数
1
解决办法
1万
查看次数

编组错误 - 缺少xmlrootelement注释错误

当我从一个Spring项目调用其中一个WSDL操作时,我得到以下异常 - com.sun.istack.internal.SAXException2: unable to marshal type "com.pkg.wsdl.ABC" as an element because it is missing an @XmlRootElement annotation

我在pom.xml中使用以下命令从WSDL(已被许多客户端使用)生成java对象作为spring项目的一部分 -

        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.13.1</version>
Run Code Online (Sandbox Code Playgroud)

看看类似的问题解决方案我改变了代码以使用JAXBElement但仍然得到相同的错误 -

    ABC vabc = new ABC();
    vabc.set(..)   // populate vabc object 

    ObjectFactory of = new ObjectFactory();
    JAXBElement<ABC> jabc = of.createABC(vabc);
    ABC oabc = jabc .getValue();
Run Code Online (Sandbox Code Playgroud)

Marshaller代码 -

Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.pkg.wsdl");
Run Code Online (Sandbox Code Playgroud)

并调用后端Web服务 -

        ABCResp response = (ABCResp) getWebServiceTemplate()
        .marshalSendAndReceive("http://host:port/svcname",oabc);
Run Code Online (Sandbox Code Playgroud)

jaxb marshalling xmlroot spring-boot

4
推荐指数
1
解决办法
5162
查看次数

spring boot build package org.junit不存在

我在构建环境中构建Spring Boot应用程序时收到以下编译错误.但是,在我的机器上运行Junit测试或构建(打包)它时,我没有看到任何错误 -

src/main/java/com/abc/tests/AbcTest.java:包org.junit不存在

这是我的pom.xml -

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
    <relativePath />
</parent>
<dependencies>........
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

以下是我试过的步骤没有成功 -
1.在依赖部分中明确依赖junit 4.12以及[4.12].

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>  
</dependency> 
Run Code Online (Sandbox Code Playgroud)
  1. 添加带有和不带2.18.1版插件的maven-surefire-plugin
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <junitArtifactName> junit:junit:4.12</junitArtifactName>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

有没有其他方法可以强制构建过程在pom.xml中使用4.12 junit版本而不是选择像3.8这样的旧版本?

谢谢

java spring unit-testing junit4 spring-boot

2
推荐指数
1
解决办法
2705
查看次数