Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.5k 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.5k users

...