小编ale*_*oid的帖子

Jackson,将字符串反序列化为日期

我具有以下JSON属性:

"created_at":"2017-12-08T10:56:01.000Z"
Run Code Online (Sandbox Code Playgroud)

我想使用Jackson以下属性反序列化JSON文档:

@JsonProperty("created_at")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-ddTHH:mm:ss.SSSZ")
private java.util.Date createdAt;
Run Code Online (Sandbox Code Playgroud)

但失败,但以下异常:

org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [class com.example.domain.Product] and content type [application/json;charset=utf-8]
    at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:119)
    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:986)
    at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:969)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:717)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:671)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:587)
Run Code Online (Sandbox Code Playgroud)

我在做什么错以及如何解决?

json jackson resttemplate

0
推荐指数
1
解决办法
762
查看次数

Spring Boot 数据源和 h2 数据库路径

在我的 Spring Boot 应用程序中,我尝试配置 H2 数据库文件夹的路径。我想通过以下路径放置它:

/home/public/h2
Run Code Online (Sandbox Code Playgroud)

配置如:

# Datasource
spring.datasource.url=jdbc:h2:file:/home/public/h2
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
Run Code Online (Sandbox Code Playgroud)

导致以下错误:

Caused by: org.h2.jdbc.JdbcSQLException: A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:file:/home/public/h2". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-197]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) ~[h2-1.4.197.jar:1.4.197]
Run Code Online (Sandbox Code Playgroud)

我也尝试过spring.datasource.url=jdbc:h2:file:~/home/public/h2 ,但没有成功。

我做错了什么以及如何正确配置路径?

datasource h2 spring-data spring-data-jpa spring-boot

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

AWS EMR Spark --properties-file 类 com.amazon.ws.emr.hadoop.fs.EmrFileSystem 未找到

emr-5.20.0我尝试使用以下命令从 AWS EMR 主节点提交 Spark 应用程序:

spark-submit --executor-memory 4g --deploy-mode cluster --master yarn --class com.example.Application --properties-file config.conf s3://example-jobs/application.jar
Run Code Online (Sandbox Code Playgroud)

但它失败并出现以下错误:

Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: Class com.amazon.ws.emr.hadoop.fs.EmrFileSystem not found
Run Code Online (Sandbox Code Playgroud)

其原因在于以下参数:

--properties-file config.conf
Run Code Online (Sandbox Code Playgroud)

我做错了什么以及如何正确地将属性文件传递到 AWS EMR Apache Spark?

amazon-web-services amazon-emr apache-spark

0
推荐指数
1
解决办法
5412
查看次数

Vaadin 14 vs Vaadin 20 用于全新项目

我是 Java 后端工程师,想开始这个全新的项目。不幸的是,对我来说使用 UI 是某种噩梦 :) 这就是为什么我正在寻找一些框架,它可以将我从低级 JavaScript 细节中抽象出来,现在看起来最好的选择是 Vaadin Flow(纯 Java)。

现在,我正在尝试选择 - Vaadin 的正确版本是什么来启动项目 - Vaadin 14 还是最近发布的 Vaadin 20?请指教。现在是开始使用 Vaadin 20 的合适时机吗?

vaadin vaadin-flow vaadin14 vaadin20

0
推荐指数
1
解决办法
69
查看次数

Java 8映射列表按键映射列表

我有以下Java代码:

List<BaseQuery> queries; 

Map<Long, List<BaseQuery>> map = new HashMap<>();
for (BaseQuery query : queries) {
    List<BaseQuery> queryList = map.get(query.getCharacteristicId());
    if(queryList == null) {
        queryList = new ArrayList<>();
        map.put(query.getCharacteristicId(), queryList);
    }
    queryList.add(query);
}
Run Code Online (Sandbox Code Playgroud)

能否请您展示如何将其转换为Java 8和流?

java java-8 java-stream

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