我试图将我的json字符串转换为java对象,我收到错误
线程"main"中的异常java.lang.NoClassDefFoundError:com/fasterxml/jackson/annotation/JsonInclude $ com,位于com.fasterxml.jackson的com.fasterxml.jackson.databind.cfg.MapperConfig.(MapperConfig.java:45). com.fasterxml.jackson.databind.ObjectMapper.(ObjectMapper.java:452)中的databind.ObjectMapper.(ObjectMapper.java:535)位于com.allianz.cmis.util.ApacheHttpClientGet.main(ApacheHttpClientGet.java:65)引起的:java.lang.ClassNotFoundException:com.fasterxml.jackson.annotation.JsonInclude $ java at java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:354)at java.lang.ClassLoader.loadClass(ClassLoader.java:425)at sun.misc.Launcher $ AppClassLoader .loadClass(Launcher.java:308)at java.lang.ClassLoader.loadClass(ClassLoader.java:358)... 4更多
这是我的json字符串和我的代码片段
json字符串
{'ctpnsw': [{'abc' , 'def' }]}
模型
public class Fields {
private List<String> ctpnsw;
public List<String> getCtpnsw() {
return ctpnsw;
}
public void setCtpnsw(List<String> ctpnsw) {
this.ctpnsw = ctpnsw;
}
}
Run Code Online (Sandbox Code Playgroud)
Java代码
ObjectMapper mapper = new ObjectMapper();
List<Fields> list = mapper.readValue(output, TypeFactory.defaultInstance().constructCollectionType(List.class,Fields.class));
System.out.println(list);
我想在spring控制器中生成UUID.我是新手,我正在探索以下内容
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
Run Code Online (Sandbox Code Playgroud)
我不想将这个uuid与任何数据库列/字段相关联,但希望它是唯一的(我不确定这是否可行)
当我尝试打印String'corrId'的值时,它总是给我null
我也试过但是corrId的值仍然是null
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private String corrId;
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么,或者我的做法是完全错误的.
提前致谢!
我想通过将 API 调用到 Angular 来获取字符串值。这是我正在做的服务文件 -
public getRespondDashboardUrl(): Observable<any> {
return this.http.get(`ref/RespondDashboardUrl`);
}
Run Code Online (Sandbox Code Playgroud)
组件文件
respondDashboardLink: string;
this.refService.getRespondDashboardUrl().subscribe(result => {
this.respondDashboardLink = result;
});
Run Code Online (Sandbox Code Playgroud)
函数返回 URL 作为字符串值https://abcd.xyz.com/Respond/App/index.html#ActionCenter/0
我得到的错误
SyntaxError: JSON.parse () at XMLHttpRequest.onLoad ( http://localhost:4000/vendor.js:33488:51 ) 在 ZoneDelegate.push../node_modules/zone.js/ dist/zone.js.ZoneDelegate.invokeTask ( http://localhost:4000/polyfills.js:8108:31 ) 在 ZoneDelegate 的 Object.onInvokeTask ( http://localhost:4000/vendor.js:78969:33 )。 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask ( http://localhost:4000/polyfills.js:8107:60 ) 在 Zone.push../node_modules/zone.js/dist /zone.js.Zone.runTask ( http://localhost:4000/polyfills.js:7880:47 ) 在 ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke ] (http://localhost:4000/polyfills.js:8183:34 ) 在 invokeTask ( http://localhost:4000/polyfills.js:9429:14 ) 在 XMLHttpRequest.globalZoneAwareCallback ( http://localhost:4000/polyfills. js:9466:21 )
我正在使用 Alfresco 并使用 Maven 覆盖功能将 amp 模块包含到单个 WAR 文件中。
这是我的 POM 文件
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at …Run Code Online (Sandbox Code Playgroud)