在spring boot中将属性放在application.yml或bootstrap.yml上有什么区别?在logging.config情况下,应用程序的工作方式不同.
我的目标是world-service从config-service.
架构:
config-service依赖spring-cloud-config-server于localhost:8888world-service依赖于spring-web和spring-cloud-starter-config。我做了什么:
http://localhost:8888/hello-service/master配置服务器hello-service.properties从config-repo 存储库中获取。(如果你需要它config-service的源代码,我会把它推送到这个仓库。)我的预期结果:world-service使用端口 8081。
我的实际结果:world-service使用端口 8080。
bootstrap.properties
spring.application.name=world-service
spring.cloud.config.uri=http://localhost:8888
Run Code Online (Sandbox Code Playgroud)
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>world-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>world-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.0-M5</spring-cloud.version>
</properties>
<dependencies>
<dependency> …Run Code Online (Sandbox Code Playgroud)