Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

java - Spring Cloud Client not fetching configuraiton from spring cloud server

I am new to Spring Cloud and I am trying to connect a server and client, using a property file stored on github.

My server application.yml file is configured as follows:

---
server:
  port: 8888
spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/JonEasy/pluralsight-spring-cloudconfig-wa-tolls.git
          #username: uname
          #password: pass
          search-paths:
            - 'station*'
          repos:
            perf:
              pattern:
                - '*/perf'
              uri: https://github.com/JonEasy/pluralsight-spring-cloudconfig-wa-tolls-perf.git
              search-paths:
                - 'station*'

The github repos are linked here Main Properties and Alternative Properties

My client application has the following setup

spring.application.name=s1rates
spring.profiles.active=default
spring.cloud.config.uri=http://localhost:8888
spring.cloud.config.enabled= true

And the Rest Controller is :

@Controller
public class RateController {

    @Value("${rate}")
    String rate;

    @Value("${lanecount}")
    String lanecount;

    @Value("${tollstart}")
    String tollstart;


    @RequestMapping("/rate")
    public String getRate(Model m) {

        m.addAttribute("rateamount", rate);
        m.addAttribute("lanes", lanecount);
        m.addAttribute("tollstart", tollstart);

        //name of the view
        return "rateview";

    }
}

All the ${variables} van be found inside the properties file located in the git repositories.

The server is executing fine but the Client is giving me the following error

Error creating bean with name 'rateController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'rate' in value "${rate}"

Also note that my spring application name "s1rates" is matching the properties files inside my main repository under station1/s1rates.properties.

Any hint?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...