我无法从另一个 spring 应用程序的spring 配置服务器中获取属性。
我可以使用浏览器获取它,因此配置服务器本身似乎很好,但是我的客户端应用程序似乎只是忽略了我应该在哪里获取属性的配置。
配置服务器很简单:
@SpringBootApplication
@EnableConfigServer
public class ConfigserverApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigserverApplication.class, args);
}
}
和 application.properties
server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=${HOME}/FH/SKS/configserver/src/main/resources/configuration
management.security.enabled=false
我现在不想使用任何 git,所以我只使用一个名为的本地文件
新闻服务-config.properties:
message=Hello configuration server !
我可以使用浏览器很好地获取属性:
..所以我猜它在我的其他配置中!
客户_
首先,我使用 application.yml 进行一般配置,如下所示:
server:
port : 8081
spring:
jpa:
generate-ddl: true
hibernate:
ddl-auto: create
show-sql: true
databasePlatform: org.hibernate.dialect.MySQL5Dialect
关于配置服务器的内容不多。除了用于配置服务器配置的 application.yml 之外,我还创建了一个bootstrap.properties文件:
spring.application.name=newsservice-config
spring.cloud.config.server.uri=http://localhost:8888
management.security.enabled=false
名称正确。(配置服务器上配置文件的名称)服务器地址正确。
我要测试所有内容的 REST 控制器:
@RefreshScope
@RestController
@RequestMapping("/article")
@CrossOrigin
public class ArticleController {
@Value("${message: Default Hello}")
private String message;
@GetMapping("/test")
public String tester(){
return this.message;
}
}
..但是它没有从配置服务器获取任何东西....
我的客户的资源结构:
任何想法我做错了什么?
亲切的问候...