【发布时间】:2021-10-08 06:33:01
【问题描述】:
我开始使用 Java + SprintBoot + AzureStorage。我刚刚使用以下配置通过 Spring 初始化程序创建了一个项目:
我正在尝试创建一个简单的 rest 方法来从 Azure 返回共享列表,但出现以下错误:
Exception Details:
Location:
com/fasterxml/jackson/databind/cfg/MapperBuilder.streamFactory()Lcom/fasterxml/jackson/core/TokenStreamFactory; @7: areturn
Reason:
Type 'com/fasterxml/jackson/core/JsonFactory' (current frame, stack[0]) is not assignable to 'com/fasterxml/jackson/core/TokenStreamFactory' (from method signature)
Current Frame:
bci: @7
flags: { }
locals: { 'com/fasterxml/jackson/databind/cfg/MapperBuilder' }
stack: { 'com/fasterxml/jackson/core/JsonFactory' }
据我所知,我的代码中没有什么特别的地方可以分享:
AzureStoreService
@Service
public class AzureStorageService {
@Value("${azure.storage.accountName}")
private String accountName;
@Value("${azure.storage.accountKey}")
private String token;
private ShareServiceClient createServiceClient() {
String shareURL = String.format("https://%s.file.core.windows.net", accountName);
return new ShareServiceClientBuilder().endpoint(shareURL).sasToken(token).buildClient();
}
public List<String> listShares() {
List<String> shares = new ArrayList<>(0);
ShareServiceClient client = createServiceClient();
client.listShares().forEach(item -> shares.add(item.getName()));
return shares;
}
}
AzureController
@RestController
@RequestMapping("/storage")
public class AzureController {
@Autowired
private AzureStorageService azureStorageService;
@GetMapping("/list-shares")
private ResponseEntity<List<String>> listShares() {
List<String> shares = azureStorageService.listShares();
return new ResponseEntity<>(shares, HttpStatus.OK);
}
}
我猜这个问题与 Spring Boot 和 Azure 之间的库版本冲突有关,但是我应该保留哪个以及如何保留。
您之前可能遇到过这个问题,欢迎任何提示/建议。
提前非常感谢!
【问题讨论】:
标签: java spring-boot azure azure-storage