Spring分析不适用于application.properties

wbrvyc0a  于 2023-08-02  发布在  Spring
关注(0)|答案(1)|浏览(69)

我想设置default profile=prod(当项目从服务器上的ci-cd执行时)和profile=local(当我从intellij idea执行项目时)。
有application.properties文件:

spring.profiles.active=prod

#Database settings
spring.datasource.url=jdbc:mysql://localhost:3306/ddauth
...

字符串
有application-local.properties文件:

spring.datasource.url=jdbc:mysql://172.17.0.2:3306/ddauth


我在IntellijIdea Run配置中设置了spring.profiles.active参数:
x1c 0d1x的数据
我也尝试使用这样的参数执行我的jar文件:
java -jar app.jar -Dspring.profiles.active=local
在任何情况下,项目都以prod模式执行。我在执行过程中收到以下消息:
2023-08-01 23:02:52 [INFO] | AuthRunner:640 The following 1 profile is active: "prod"
我读了很多不同的教程,没有任何想法,它是如何工作的。我知道我也可以在bootJar任务中设置这个配置文件参数,但我不想这样做。我想实现这个简单的解决方案,并找出为什么它不工作。

mfpqipee

mfpqipee1#

您需要将-Dspring.profiles.active=local作为JVM参数传递。

相关问题