【发布时间】:2019-12-20 09:43:58
【问题描述】:
我已经在 application.properties 文件中添加了“spring.profiles.active=local” 但是在运行应用程序时,它无法识别配置文件并使用默认配置文件运行
application.properties
# Tomcat Server Config
server.port=8071
#Profile Config
spring.profiles.active=local
application-local.properties
# Spring JPA Config
spring.datasource.url=jdbc:postgresql://localhost:5432/User
spring.datasource.username=postgres
spring.datasource.password=amt123`
# Hibernate Config
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=none
【问题讨论】:
-
您的
application.properties文件在哪里? -
欢迎来到 SO。请不要将您的代码发布为场外图像。请将您的代码和(错误)消息粘贴到您的问题中。您可以使用格式正确地格式化您的代码。有关如何提问的更多信息,请参阅stackoverflow.com/help/how-to-ask。有关格式化的更多信息,请参阅stackoverflow.com/editing-help。
-
当我使用“java -jar”命令运行 jar 文件时,它正在使用指定的配置文件运行,但是当我使用 IDE 运行时,它无法检测到配置文件并回退到默认配置文件跨度>
-
@cassiomolin 它位于 src/main/resources