java - SpringBoot - Java AWS SDK 2 DynamoDB 增强客户端和开发工具问题
问题描述
我正在使用 Spring Boot 2.17 和 java sdk 以及 dynamodb-enhanced '2.13.8'。
我正在与增强型客户端调用这样的项目:
public Product readProductById(String id) {
Key key = Key.builder()
.partitionValue(id)
.build();
Product product = productTable.getItem(key);
return product;
}
调用此错误时会导致:
class de.xxx.productsapi.db.Product cannot be cast to class de.xxx.productsapi.db.Product (de.xxx.productsapi.db.Product is in unnamed module of loader 'app'; de.xxx.productsapi.db.Product is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @19e19c7e)
java.lang.ClassCastException: class de.xxx.productsapi.db.Product cannot be cast to class de.xxx.productsapi.db.Product (de.xxx.productsapi.db.Product is in unnamed module of loader 'app'; de.xxx.productsapi.db.Product is in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @19e19c7e)
切换livereload to enabled: false
并没有帮助,但完全删除了 devtools 工作。但这是一个不令人满意的解决方案,因为我想使用 devtools。
感谢帮助
解决方案
Spring Boot DevTools 重启功能是使用两个类加载器实现的。项目由重启类加载器加载,库由基类加载器加载。
使用该文件META-INF/spring-devtools.properties
将 DynamoDB jar 移动到RestartClassloader
:
restart.include.dynamodb=/dynamodb-[\\w\\d-\.]+\.jar
推荐阅读
- sql-server-2008 - SQL Server Update Case When Then 语句
- django - 基于 Django 函数的视图 get_form_kwargs
- android - 即使在包含 lint 操作之后也没有创建 jar
- angularjs - 剑道网格导出到 excel - 从右到左支持
- function - CMake:如何从函数内部修改变量
- node.js - 当我通过 app.js 中的 foreach 添加路由时,Router.use() 抛出错误
- php - cURL 错误 56:在发送 xml 请求时从对等方接收数据失败
- ruby-on-rails - 使用 http 在 Rails 中共享模型数据
- ios - 无法在 Xcode 10/iOS 12 中进行自定义 segue
- sql - SAS 过程 SQL;- 创建日期时间变量