我已经在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
答案 0 :(得分:0)
“ spring.devtools.add-properties”默认值为true 一旦将其设置为false,spring boot就会禁用配置文件配置。 对我来说,即使将值设置为true,仍未启用配置文件配置
我通过删除dev-tool依赖项并再次添加来解决此问题。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
我不确定内部工作流程。 如果有人对此有适当的解释,请发表评论