gpt4 book ai didi

java - 从位置 'spring.profiles.active' 导入的属性 'class path resource [application-dev.yml]' 无效

转载 作者:行者123 更新时间:2023-12-04 12:04:46 24 4
gpt4 key购买 nike

我将 Spring 云应用程序更新到最新的 Spring boot 版本 2.5.0。
但是在启动过程中我得到了这个异常:

11:05:05.038 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
org.springframework.boot.context.config.InvalidConfigDataPropertyException: Property 'spring.profiles.active' imported from location 'class path resource [application-dev.yml]' is invalid in a profile specific resource [origin: class path resource [application-dev.yml] from skyshop-mail-1.0.jar - 42:17]
at org.springframework.boot.context.config.InvalidConfigDataPropertyException.lambda$throwOrWarn$1(InvalidConfigDataPropertyException.java:125)
application.yml
spring:
application:
name: mail-service
profiles:
active: dev
application-dev.yml 文件:
logging:
file:
name: ${java.io.tmpdir}/application.log
level:
com:
backend: DEBUG
org:
springframework: DEBUG
springframework.web: DEBUG
jwt:
expiration: 86400
secret: test112322
server:
port: 8020
servlet:
context-path: /mail
spring:
application:
name: mail-service
profiles:
active: local
data:
web:
pageable:
one-indexed-parameters: true # Fix pagination starting number to start from 1
rest:
basePath: /mail
jackson:
default-property-inclusion: non_null
jmx:
enabled: false
datasource:
url: jdbc:mariadb://localhost:3306/database
driverClassName: org.mariadb.jdbc.Driver
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDBDialect
show-sql: true
username: root
password: qwerty
oauth2:
resource:
jwt:
key-pair:
alias: mytestkey
store-password: mystorepass
info:
build:
version: 1.0
eureka:
client:
serviceUrl:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
instance:
preferIpAddress: true
你知道我该如何解决这个问题吗?

最佳答案

Spring Boot 2.4 改进了 application.properties 和 application.yml 文件的处理方式。
详情请看这里:https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Config-Data-Migration-Guide
长话短说:如果你有一个 application-local.yml 并且你在里面定义了

spring:
profiles:
active: local
然后只需在 yaml 文件中删除此条目。

关于java - 从位置 'spring.profiles.active' 导入的属性 'class path resource [application-dev.yml]' 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67935961/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com