我收到以下错误:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.11.BUILD-SNAPSHOT)
2021-05-07 08:09:51.509 INFO 10436 --- [ main] c.m.c.CoursecatalogserviceApplication : No active profile set, falling back to default profiles: default
2021-05-07 08:09:53.528 WARN 10436 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2021-05-07 08:09:53.570 WARN 10436 --- [ main] o.s.boot.actuate.endpoint.EndpointId : Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format.
2021-05-07 08:09:53.883 INFO 10436 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=80320ea5-f121-3bc0-89ba-dd89196e504a
2021-05-07 08:09:55.670 INFO 10436 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 6061 (http)
2021-05-07 08:09:55.688 INFO 10436 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-05-07 08:09:55.688 INFO 10436 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.45]
2021-05-07 08:09:55.969 INFO 10436 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-05-07 08:09:55.969 INFO 10436 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4429 ms
2021-05-07 08:09:56.278 WARN 10436 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-05-07 08:09:56.278 INFO 10436 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-05-07 08:09:56.293 INFO 10436 --- [ main] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@27abb6ca
2021-05-07 08:09:57.599 WARN 10436 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-05-07 08:09:57.600 INFO 10436 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-05-07 08:09:58.377 INFO 10436 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-05-07 08:10:00.804 INFO 10436 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2021-05-07 08:10:03.230 INFO 10436 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2021-05-07 08:10:03.249 INFO 10436 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses Jersey
2021-05-07 08:10:03.453 WARN 10436 --- [ main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
2021-05-07 08:10:03.617 INFO 10436 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-05-07 08:10:03.710 INFO 10436 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2021-05-07 08:10:03.835 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2021-05-07 08:10:04.780 INFO 10436 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-05-07 08:10:04.780 INFO 10436 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-05-07 08:10:05.042 INFO 10436 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-05-07 08:10:05.042 INFO 10436 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-05-07 08:10:05.347 INFO 10436 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-05-07 08:10:05.938 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2021-05-07 08:10:05.938 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2021-05-07 08:10:05.938 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2021-05-07 08:10:05.938 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2021-05-07 08:10:05.953 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2021-05-07 08:10:05.953 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2021-05-07 08:10:05.953 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2021-05-07 08:10:06.240 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2021-05-07 08:10:06.245 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2021-05-07 08:10:06.249 INFO 10436 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2021-05-07 08:10:06.256 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1620393006254 with initial instances count: 2
2021-05-07 08:10:06.264 INFO 10436 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application CATALOG-SERVICE with eureka with status UP
2021-05-07 08:10:06.264 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1620393006264, current=UP, previous=STARTING]
2021-05-07 08:10:06.273 INFO 10436 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CATALOG-SERVICE/localhost:catalog-service:6061: registering service...
2021-05-07 08:10:06.336 INFO 10436 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CATALOG-SERVICE/localhost:catalog-service:6061 - registration status: 204
2021-05-07 08:10:06.338 INFO 10436 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 6061 (http) with context path ''
2021-05-07 08:10:06.340 INFO 10436 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 6061
2021-05-07 08:10:08.198 INFO 10436 --- [ main] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2021-05-07 08:10:08.212 WARN 10436 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.catelogController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'test.host.name' in value "${test.host.name}"
2021-05-07 08:10:08.227 INFO 10436 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-05-07 08:10:08.258 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2021-05-07 08:10:11.265 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Unregistering ...
2021-05-07 08:10:11.290 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CATALOG-SERVICE/localhost:catalog-service:6061 - deregister status: 200
2021-05-07 08:10:11.306 INFO 10436 --- [ main] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2021-05-07 08:10:11.812 INFO 10436 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-05-07 08:10:11.828 INFO 10436 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-05-07 08:10:11.859 ERROR 10436 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.catelogController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'test.host.name' in value "${test.host.name}"
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:363) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:389) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:186) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1109) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.cloud.context.scope.refresh.RefreshScope.eagerlyInitialize(RefreshScope.java:127) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.cloud.context.scope.refresh.RefreshScope.start(RefreshScope.java:118) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:112) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:66) ~[spring-cloud-context-2.2.8.BUILD-SNAPSHOT.jar:2.2.8.BUILD-SNAPSHOT]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:898) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.11.BUILD-SNAPSHOT.jar:2.3.11.BUILD-SNAPSHOT]
at com.microservices.coursecatalogservice.CoursecatalogserviceApplication.main(CoursecatalogserviceApplication.java:16) [classes/:na]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'test.host.name' in value "${test.host.name}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) ~[spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239) ~[spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:918) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1248) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.14.RELEASE.jar:5.2.14.RELEASE]
... 28 common frames omitted
当我尝试将一些简单的属性注入控制器时。这是我的代码的样子:
文件名:catalog-service.properties
test.host.name=localhost
test.version.number = 1.0
test.last.updated = 5/7/2021
package com.microservices.coursecatalogservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableCircuitBreaker
@EnableDiscoveryClient
public class CoursecatalogserviceApplication {
public static void main(String[] args) {
SpringApplication.run(CoursecatalogserviceApplication.class, args);
}
}
目录服务 application.properties 文件存在于本地
server.port=6061
spring.application.name=catalog-service
eureka.client.register-with-eureka=true
目录控制器
package com.microservices.coursecatalogservice.controller;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.security.SecurityProperties.User;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import com.microservices.coursecatalogservice.object.Course;
import com.netflix.appinfo.InstanceInfo;
import com.netflix.discovery.EurekaClient;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
@RestController
public class CatelogController {
@Value(("${test.host.name}"))
private String hostname;
@Value(("${test.version.number}"))
private String version;
@Value(("${test.last.updated}"))
private String lastUpdated;
@Autowired
private EurekaClient client;
@GetMapping("/")
@HystrixCommand(fallbackMethod = "displayDefaultHome")
public String getCatalogHome() {
String courseAppMessage = "";
InstanceInfo instanceInfo = client.getNextServerFromEureka("course-app", false);
RestTemplate restTemplate = new RestTemplate();
String courseAppUrl = instanceInfo.getHomePageUrl();
courseAppMessage = restTemplate.getForObject(courseAppUrl, String.class);
return ("Welcome to the course catelog " + courseAppMessage);
}
@GetMapping("/info")
public String checkConfig() {
return "";// "The version of the application is: "+hostname+ "<br> The application was last updated: "+hostname+" <br> The application is hosted on: "+hostname;
}
public String displayDefaultHome() {
return "The course app service is down, please try after some time";
}
@GetMapping("/catalog")
public List<Course> getCatalog() {
List<Course> courseAppMessage = null;
InstanceInfo instanceInfo = client.getNextServerFromEureka("course-app", false);
RestTemplate restTemplate = new RestTemplate();
String courseAppUrl = instanceInfo.getHomePageUrl() + "/course/all";
courseAppMessage = (List<Course>)restTemplate.getForObject(courseAppUrl,List.class);
return (courseAppMessage);
}
@GetMapping("/catalog/course/{id}")
@HystrixCommand(fallbackMethod = "displayDefaultHome")
public Course getCourse(@PathVariable String id) {
Course course = null;
InstanceInfo instanceInfo = client.getNextServerFromEureka("course-app", false);
RestTemplate restTemplate = new RestTemplate();
String courseAppUrl = instanceInfo.getHomePageUrl() + "/course/"+id;
course = (Course)restTemplate.getForObject(courseAppUrl,Course.class);
return course;
}
@GetMapping("/catalog/student/{id}")
public List<User> getSpecificCourse(@PathVariable BigInteger id) {
Course course = new Course();
InstanceInfo instanceInfo = client.getNextServerFromEureka("user-app", false);
RestTemplate restTemplate = new RestTemplate();
String courseAppUrl = instanceInfo.getHomePageUrl() + "/users/course"+id;
List<User> users = (List<User>)restTemplate.getForObject(courseAppUrl,List.class);
return users;
}
public List<Course> displayDefaultCatalog() {
return new ArrayList<>();
}
}
发现服务器主类
package com.microservices.discoveryserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryserverApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryserverApplication.class, args);
}
}
发现服务器属性文件
server.port = 8761
spring.application.name=fx-discovery-server
eureka.client.register-with-eureka =false
eureka.client.fetch-registry=false
配置服务器主类
package com.microservices.configserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableDiscoveryClient
@EnableConfigServer
public class ConfigserverApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigserverApplication.class, args);
}
}
配置服务器属性文件
server.port=8888
spring.application.name=config-server
spring.cloud.config.server.git.uri=https://github.com/tadhikari/MicroserviceCentralRepo.git
spring.cloud.config.server.git.default-label=main
当我跑步时
http://localhost:8888/catalog-service/default
我明白了
{
"name": "catalog-service",
"profiles": [
"default"
],
"label": null,
"version": "63a93cca7745ecdf4eedea234a5ba683a4041f36",
"state": null,
"propertySources": [
{
"name": "https://github.com/tadhikari/MicroserviceCentralRepo.git/file:C:\\Users\\jojo\\AppData\\Local\\Temp\\config-repo-8179769206293496317\\catalog-service.properties",
"source": {
"test.host.name": "localhost",
"test.version.number": "1.0",
"test.last.updated": "5/7/2021"
}
}
]
}