Java Can';使用SpringCloudConfigServer无法从配置文件中获取信息
我在git存储库中存储了一个配置文件,它 message.properties 其中包含一行 message service.senderName=Katya 我有一个简单的项目,它从上面的存储库中获取数据。 我有 DemoApplication.java 应用程序属性 及 pom.xmlJava Can';使用SpringCloudConfigServer无法从配置文件中获取信息,java,spring,spring-cloud,configserver,Java,Spring,Spring Cloud,Configserver,我在git存储库中存储了一个配置文件,它 message.properties 其中包含一行 message service.senderName=Katya 我有一个简单的项目,它从上面的存储库中获取数据。 我有 DemoApplication.java 应用程序属性 及 pom.xml 4.0.0 org.springframework.boot link您是否正在学习一些教程。因为这里有很多错误。首先,属性文件应称为application.properties。第二。您不能使用这样的链接
4.0.0
org.springframework.boot
link您是否正在学习一些教程。因为这里有很多错误。首先,属性文件应称为application.properties。第二。您不能使用这样的链接访问它。@pvpkiran,据我所知,我尝试按照本教程中的说明进行操作,但如果我将application.properties中的方向更改为this spring.cloud.config.server.git.uri=我看到的文本与教程中的一样,您是否遵循了某些教程。因为这里有很多错误。首先,属性文件应称为application.properties。第二。您不能使用这样的链接访问它。@pvpkiran,据我所知,我试图按照本教程所说的去做,但这不起作用。但如果我将application.properties中的方向改为this spring.cloud.config.server.git.uri=我看到的文本与本教程中的一样,则此示例会起作用
@SpringBootApplication
@EnableConfigServer
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
server.port=8881
spring.cloud.config.server.git.uri=https://github.com/katya-dovgalets/config.git
<?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.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>