如果你的客户端向服务端请求了git的配置文件,@value成功加载后,再通过页面进不去控制层,可能是因为客户端请求到了配置文件的同时,配置文件里配置了port端口号,把客户端的端口号覆盖掉了。代码如下
这是springboot的启动类
package com.new0409.new0409;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
@EnableDiscoveryClient
@SpringBootApplication
public class New0409Application {
@Bean
@LoadBalanced
RestTemplate restTemplate(){
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(New0409Application.class, args);
}
}
这是controller层
package com.a1824.demo.controller;
import org.springfra