- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法从 git 读取属性在 spring-cloud-config-server ,
我有两个应用程序配置客户端和配置服务器,我想从配置客户端读取配置服务器 git 中存在的属性存储库。
请在下面找到我的代码:
配置客户端
ConfigClientApplication.java
@SpringBootApplication
public class ConfigClientApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigClientApplication.class, args);
}
}
消息资源.java
@RestController
@RequestMapping("/rest")
public class MessageResource {
@Value("${message: Defalut Hello}")
private String message;
@GetMapping("")
public String getMessage() {
return message;
}
}
bootstrap.properties
spring.application.name=config-client
server.port=8091
management.endpoints.web.exposure.include=*
spring.cloud.config.uri=http://localhost:8888
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 http://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.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.bhaskar.shopping</groupId>
<artifactId>config-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>config-client</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.M3</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</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>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
配置服务器
ConfigServerApplication.java
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
bootstrap.properties
spring.config.name=configserver
server.port = 8888
spring.cloud.config.server.git.uri=https://github.com/BijayaBhaskar/micro-service-config-server
spring.cloud.config.server.git.clone-on-start=true
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 http://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.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.bhaskar.shopping</groupId>
<artifactId>config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>config-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.M3</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>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
配置客户端.properties
message = Hello World
我已在定义的 git URL 中提交了此文件,但我无法在其余 API 中获取消息属性。
当我启动配置客户端应用程序时,它会访问配置服务器 URL 但返回默认属性,
这是我的客户端和服务器日志。
配置客户端日志
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.1.RELEASE)
2018-12-07 17:26:36.613 INFO 9336 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2018-12-07 17:26:38.402 INFO 9336 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config-cilent, profiles=[default], label=null, version=a611374438e75aa1b9808908c57833480944e1a8, state=null
2018-12-07 17:26:38.402 INFO 9336 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://github.com/spring-cloud-samples/config-repo/application.yml (document #0)'}]}
2018-12-07 17:26:38.402 INFO 9336 --- [ main] c.b.shopping.ConfigClientApplication : No active profile set, falling back to default profiles: default
2018-12-07 17:26:38.992 INFO 9336 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=e4575a9f-f04b-3f9f-93b8-2da140e2fcba
2018-12-07 17:26:39.002 INFO 9336 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$11855985] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-12-07 17:26:39.223 INFO 9336 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8091 (http)
2018-12-07 17:26:39.243 INFO 9336 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-12-07 17:26:39.243 INFO 9336 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13
2018-12-07 17:26:39.253 INFO 9336 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre8\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;C:\Program Files\nodejs\;D:\Spott_Software\apache-maven-3.5.3\bin;C:\Program Files\Java\jdk1.8.0_11\bin;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Users\bijayas\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\bijayas\AppData\Local\Programs\Python\Python37\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft VS Code\bin;C:\Users\bijayas\AppData\Roaming\npm;.]
2018-12-07 17:26:39.493 INFO 9336 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-12-07 17:26:39.493 INFO 9336 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1081 ms
2018-12-07 17:26:39.674 INFO 9336 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2018-12-07 17:26:40.247 INFO 9336 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8091 (http) with context path ''
2018-12-07 17:26:40.247 INFO 9336 --- [ main] c.b.shopping.ConfigClientApplication : Started ConfigClientApplication in 4.989 seconds (JVM running for 5.806)
配置服务器日志
2018-12-07 17:26:36.749 INFO 7320 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2018-12-07 17:26:36.749 INFO 7320 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2018-12-07 17:26:36.759 INFO 7320 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 10 ms
2018-12-07 17:26:38.301 INFO 7320 --- [nio-8888-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/bijayas/AppData/Local/Temp/config-repo-9103792242838281221/application.yml (document #0)
在这里我可以看到它是从不同的目录加载的,而不是从 bootstrap.properties 中定义的 GIT 存储库加载的,请帮助我。
提前致谢。
最佳答案
缺少添加 your repository config-client.properties,因为您有一个名为catalog-service.properties。
如果这对您有帮助,请告诉我。
已更新
此外,您还需要更新一些内容。
配置服务器
根据documentation配置名称必须与项目名称相同。
spring.config.name=config-server
配置客户端
将 application.properties 重命名为 bootstrap.properties,因为当您放置 bootstrap 时,会在应用程序上下文之前读取属性。
关于java - 无法从Spring云配置服务器中的GIT读取属性源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53669140/
语境 我正在将一个旧的 php 电子商务网站变成一个用 gatsby.js 构建的静态网站。 我将所有产品元数据放入单独的 .json 文件(每个产品一个),并且我能够使用 json 和文件转换器插件
我曾经能够使用三指向上滚动在源/标题之间切换。自从升级到 Lion 后,我只进行常规滚动。有没有办法恢复该功能? Aka,当我像以前那样向上/向下滚动时,它不会跳到对应的位置。 更新 Apple 在
我有一个包含复选框输入的克隆元素。当克隆的元素未被选中时,我需要也取消选中源元素。有没有办法在 jQuery 中做到这一点?或者我是否以错误的方式处理这个问题(即使用clone())?我应该提到我的问
我有一个类,其中有两个 JSpinner 对象,x 和 y。我有一个更改监听器,它已添加到两者中。有人可以告诉我如何实现我的更改监听器,以便监听器可以区分两个对象之间的区别。例如伪代码: if(sou
我正在编写涉及 for 循环的代码,该循环在每个索引处进行计算。 这些计算中的最小值存储在一个变量中,我在程序末尾使用 MPI_Allreduce 来确定所有进程的全局最小值。 但是,我需要一种方法来
我需要在一个 Android 项目中创建一个 map View ,我从服务器获取自定义 map 图 block PNG。有人知道实现此类功能的简单许可 API 吗? 最佳答案 我使用了 OsmDroi
因为我必须创建一个可以更改图像 (src/background-url) 的函数。我想知道如何识别标签以及它是使用 src 还是 url 来访问图像。 让我们说 早些时候我写了一个可以
当我使用源 map 浏览器 https://github.com/danvk/source-map-explorer要检查捆绑包中的内容,我得到以下输出: D:\projects\angular\mT
我正在为客户将 Windev 应用程序移植到 Objective-C。出于显而易见的原因,使用以前的源代码会更简单。 不幸的是,它是加密的,我需要 EDI 才能看到它;完整版的 Windev 太贵了(
我有一个简单的视频播放器,它使用 WPF MediaElement 播放一系列视频。这些视频一起形成一个围绕静止图像移动的连续电影。在每个视频结束时,运动会卡住在当前播放视频的最后一帧。当我按下一个按
我需要更改 openlayer 的图层源(使用 open weather api)。目前我正在使用以下代码但没有成功。 let layer = this.map.getLayers().getArra
我正在尝试在 /dev/random 的机器上运行代码不会很快填满,我正在尝试使用的 Java 程序因缺少随机数而挂起。/dev/urandom产生“不太好”的随机数,但不会阻塞,对于这种情况,我宁愿
我需要 Yocto 项目的源代码包。我已经拥有整个项目的所有资源,但它们还包括开发工具。 我想有一种方法来生成将为目标图像构建的所有包的(修补的)源。因此,例如,如果目标图像包含 busybox,我想
如何对入侵者隐藏 iFrame src 假设我正在流式传输我的网络摄像头或我的电脑屏幕,这是 iframe 代码: 并且我不希望它在大多数浏览器上显示页面源中的流 URL 和检查功能! 这意
是否可以进入 Qt 源,例如qmainwindow.cpp,在 Qt Creator 中?目前我正在看到反汇编,但最好能看到源代码。 最佳答案 当然!但您可能必须首先: 转到 $QT_HOME/qt
我正在尝试创建一个包含很少动漫剧集的简单网站。我有一个关于 javascript 的问题。如何通过单击我的链接之一来更改视频源?我明白,我必须使用事件监听器,只需更改 取决于我点击的链接,但我不太擅长
我有一个带有 BindingSouce 的 DevExpress GridControl。我想清除 BindingSource 并用新数据填充它。我这样做: var list = new List()
当单击提交输入按钮时,我尝试将其他参数(选定复选框的列表)传递到服务器处理的 DataTables 表#my_table: 这可能意味着我必须将 my_table.sAjaxSource 设置为后端脚
(好吧,别对我大喊大叫,这里已经很晚了:)) 我正在研究 delta diff 工具(命令行工具或组件,只要我可以从 Delphi 2010 调用它们就可以了) 我有这个项目,我将文件上传到服务器,我
我需要解析 Yahoo Weather RSS feed 中的某个位置,例如 http://weather.yahooapis.com/forecastrss?w=44418&u=c例如,获取最高、最
我是一名优秀的程序员,十分优秀!