Azure 数据块中的 Spring 版本

Posted

技术标签:

【中文标题】Azure 数据块中的 Spring 版本【英文标题】:Spring Version in Azure databricks 【发布时间】:2021-02-18 03:05:37 【问题描述】:

我目前正在使用 spring boot 2.3.0 版本在 java 中构建一个 apache spark 作业。这份工作在我当地工作得很好。我想在 Azure databricks(7.2.0) 上部署这个 Spring Boot Spark 作业。但是在 Azure databricks 上部署 spring boot jar 时,出现以下错误 -

ava.lang.NoSuchMethodError: org.springframework.core.ResolvableType.forInstance(Ljava/lang/Object;)Lorg/springframework/core/ResolvableType;
    at org.springframework.context.event.SimpleApplicationEventMulticaster.resolveDefaultEventType(SimpleApplicationEventMulticaster.java:145)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)

我检查了 azure databricks 文档,它在 azure databricks 上默认安装了 spring core 4.1.3,在我的代码中 spring core 版本是 5.2.8。所以,我想问一下有没有什么办法可以在azure databricks上升级spring core版本。

【问题讨论】:

【参考方案1】:

要使第三方或本地构建的代码可用于集群上运行的笔记本和作业,您可以安装一个库。库可以用 Python、Java、Scala 和 R 编写。您可以上传 Java、Scala 和 Python 库并指向 PyPI、Maven 和 CRAN 存储库中的外部包

在 Azure Databricks 中安装 Spring 版本的步骤:

第一步:从 Maven 仓库下载 spring 核心库。点击jar文件下载。

第 2 步:选择要在其中安装库的集群。

Libraries => Install New => Library Source: "Upload", Library Type: "Jar"​​, 点击 drop here 并选择之前下载的 jar 文件 => 点击 install。

成功,在集群上安装spring_core_5_2_8库。

有关在 Azure Databricks 中安装包的不同方法,请参阅:How to install a library on a databricks cluster using some command in the notebook?

【讨论】:

我尝试使用 spring boot 2.3.12.RELEASE 启动 jar,添加 spring_core_5_2_16_RELEASE.jar 作为库 - 没有成功。同样的错误“用户代码中未捕获的可抛出:java.lang.NoSuchMethodError:org.springframework.core.ResolvableType.forInstance”

以上是关于Azure 数据块中的 Spring 版本的主要内容,如果未能解决你的问题,请参考以下文章

将数据写入 Azure 数据块中的 Delta Lake 时出现问题(检测到不兼容的格式)

前端 (HTML) 未从 Microsoft Azure 中的 mysql 数据库获取 Spring Boot 应用程序中的数据

如果我们保持空闲一段时间,则在连接到 Azure MSSQL DB 时,Spring Boot 应用程序中的数据库连接将关闭

Azure Databricks 的 Azure DevOps 管道

Azure下载blob部分

如何从 angular localhost:4200 调用 spring security azure AD localhost:8080。天蓝色调用中的错误