我试图创建一个Spring Cloud配置服务器,它从属性文件中读取配置数据而不是github。服务器启动,但不提供文件中的属性。我对classpapath两个配置文件:Spring-Cloud配置服务器忽略配置属性文件
bootstrap.yml
spring:
application:
name: config-server
config-server.properties
foo=bar
当我去据称应该给我的值的URL foo楼盘:
curl http://localhost:8888/admin/env/foo
我得到一个错误: “时间戳“:1415298615005,”status“:404,”error“:”Not Found“,”exception“:”org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint $ NoSuchPropertyException“,”message“:”No such property :foo“,”path“:”/ admin/env/foo“}
我在想我在做什么错?据我了解,属性文件名应该与服务器名称匹配以便被服务器识别。
作为spencergibb添加本机配置文件建议没有帮助。我application.properties样子:
server.port=8888
spring.profiles.active=native
spring.config.name=configserver
spring.application.name=configserver
注意,我必须指定服务器端口。根据Spring Cloud Config Server文档,配置服务器默认启动端口8888。在我来说,不过除非我指定我的配置在服务器启动的端口在8080
的POM文件没有父母和一个单一的依赖性:
org.springframework.cloud
spring-cloud-config-server
1.0.0.M2
应用程序有没有什么特别的吧:
@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableConfigServer
public class ConfigurationApp {
public static void main(String[] args) {
SpringApplication.run(ConfigurationApp.class, args);
}
}
的configserver.properties文件包含一个条目:富=酒吧
首先我总是得到一个启动错误
2014-11-07 09:35:42.852 ERROR 6972 — [ main] b.c.PropertySourceBootstrapConfiguration : Could not locate PropertySource: I/O error on GET request for “http://localhost:8888/configserver/default/master”:Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
不管哪个命令我执行我总是从服务器获取的相同的响应的:
{“name”:”info”,”label”:”master”,”propertySources”:[{“name”:”bootstrap”,”source”:{}},{“name”:”applicationConfig: [classpath:/application.properties]”,”source”:{“spring.config.name”:”configserver”,”spring.application.name”:”configserver”,”server.port”:”8888″,”spring.profiles.active”:”native”}},{“name”:”defaultProperties”,”source”:{“spring.application.name”:”bootstrap”}}]}
我尝试:
http://localhost:8888/configserver/env
http://localhost:8888/configserver/env/foo
http://localhost:8888/configserver/info
http://localhost:8888/configserver/beans
http://localhost:8888/configserver/health
的响应总是如上
2014-11-06
MrkK