spring - 如何为开发属性禁用 spring-cloud 配置服务器

标签 spring spring-boot spring-cloud

我将 Spring Cloud 集成到我的 Spring 应用程序中。它工作正常。但我有 3 个属性文件: application.properties

server.port 9101

spring.profiles.active=@env@
logging.level.org.springframework.data=debug
logging.level.=error

application-dev.properties

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true 
spring.jpa.hibernate.use-new-id-generator-mappings=true

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

#TRACE DEBUG or INFO
logging.level.org.hibernate.type=INFO
spring.application.name=microservice-payment
spring.cloud.config.enabled = false

spring.jpa.properties.hibernate.type=trace 
spring.datasource.url=jdbc:postgresql://localhost:5432/gara-mpayment
spring.datasource.username=garauser
spring.datasource.password=garauser
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.initialization-mode=always
server.servlet.session.timeout=10s


#RabbitMq configuration
rabbitmq.queueName=mpayment.queue
rabbitmq.exchangeName=mpayment-exchange
rabbitmq.routingKey=mpayment.routingkey

和 applictaion-int.properties

spring.cloud.config.server.git.uri=my-url
spring.cloud.config.server.git.username=username
spring.cloud.config.server.git.password=pwd

我可以为开发配置文件禁用 spring cloud 以便使用 application-dev.properties 的本地内容并仅为 applictaion-int.properties 激活吗?

我试过 spring.cloud.config.enabled=false spring.cloud.bootstrap.enabled=false 没有成功。

最佳答案

您应该制作一个 bootstrap.yml 或属性文件并添加 spring.cloud.config.enable=false

或者设置环境变量并禁用spring cloud

https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html

有关您提到的错误,请参阅上面的链接 无效的配置服务器配置。操作:如果您使用的是 git 配置文件,则需要在配置中设置 Git URI。如果您使用的是 native 配置文件并且有 spring.cloud.config.server.bootstrap=true,则需要使用复合配置

关于spring - 如何为开发属性禁用 spring-cloud 配置服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58924655/

相关文章:

java - 带有 Eureka 服务器的 Spring Boot 1.4.2.RELEASE - 异常 : org. springframework.beans.factory.NoSuchBeanDefinitionException

java - 服务器如何停止已经正在处理的请求?

spring - 如何在 Spring Data 中使用 OrderBy 和 findAll

java - 如何使用具有 Autowiring 依赖项的 init 方法?

gradle - 将自定义JVM参数添加到Spring Boot生成的bat/sh脚本

java - Spring 启动 JPA : @Modifying @Query has no effect

java - 如何使用Spring Boot处理Rest API中的异常

java - Oracle Blobs - 存储大小还是计算?

java - 如何让 Spring 打印出哪些 Spring 配置文件处于 Activity 状态?

spring-cloud - 无法使用 spring-cloud-starter-aws-secrets-manager-config 通过区域提供者链找到区域