我在 Ubuntu 上启动并运行了一个 quarkus 项目,并且我的开发环境运行良好。然后我升级到 Mac 并克隆了该项目,运行
mvn quarkus:dev
期望一切正常,但遗憾的是事实并非如此:(
我遇到了一个令人讨厌的堆栈跟踪,告诉我
quarkus.datasource.url
和 quarkus.datasource.driver
已被弃用并从 quarkus 版本 1.3 和 1.9 中删除。问题是我不使用这些属性!!
这是我的application.properties
quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/db?sslmode=disable
quarkus.datasource.username=admin
quarkus.datasource.password=password
quarkus.liquibase.migrate-at-start=true
quarkus.liquibase.change-log=db/changelog/db.changelog-master.xml
这是堆栈跟踪
Caused by: io.quarkus.runtime.configuration.ConfigurationException: quarkus.datasource.url and quarkus.datasource.driver have been deprecated in Quarkus 1.3 and removed in 1.9. Please use the new datasource configuration as explained in https://quarkus.io/guides/datasource.
at io.quarkus.agroal.deployment.AgroalProcessor.build(AgroalProcessor.java:76)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:972)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
我很困惑,因为这是在一台机器上运行,而不是在另一台机器上运行!关于如何通过这个的任何提示/想法?
根据配置源,quarkus 考虑了多个源。主要是
(400) 系统属性
(300) 环境变量
(295) 当前工作目录中的 .env 文件
(260) $PWD/config/application.properties 中的 Quarkus 应用程序配置文件
(250) 类路径中的 Quarkus 应用程序配置文件 application.properties
(100) MicroProfile Config 配置文件 META-INF/microprofile-config.properties 在类路径中
此外,在
smallrye.config.locations
属性或 SMALLRYE_CONFIG_LOCATIONS
环境变量定义的位置中找到的属性。
当
quarkus.kubernetes.app-config-map=<name of the config map containing the configuration>
用作以下步骤的单步替代时,也会设置此设置:
Quarkus 支持从外部位置传递配置(通过 Smallrye Config)。这通常需要设置额外的环境变量或系统属性。当您需要使用机密或配置映射来进行应用程序配置时,您需要:
定义一个体积
安装卷
为 SMALLRYE_CONFIG_LOCATIONS 创建环境变量
因此,在任何一种情况下,都必须小心,具有更高排序序数的属性源不会覆盖 application.properties 提供的默认值。
更改 application.properties 并使用具有以下语法的 application.yml 夸库斯: 数据源: 数据库类型:postgresql 数据库连接: url: jdbc:postgresql://localhost:5432/db?sslmode=disable 用户名: 管理员 密码: 密码 驱动程序:org.postgresql.Driver 液体碱: 开始时迁移:true 更改日志:db/changelog/db.changelog-master.xml