我正在尝试使用默认的git后端设置Spring Cloud Config Server.我已经设置了一个本地gitlab并将配置文件放入本地gitlab.但是当我启动配置服务器时,抛出以下异常,我哪里出错了?是否有任何方法可以JGitEnvironmentRepository默认配置不验证SSL?
org.eclipse.jgit.api.errors.RefNotFoundException: Ref master can not be resolved
at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:244)
at org.springframework.cloud.config.server.JGitEnvironmentRepository.checkout(JGitEnvironmentRepository.java:208)
at org.springframework.cloud.config.server.JGitEnvironmentRepository.loadEnvironment(JGitEnvironmentRepository.java:179)
at org.springframework.cloud.config.server.JGitEnvironmentRepository.findOne(JGitEnvironmentRepository.java:155)
at org.springframework.cloud.config.server.EnvironmentController.labelled(EnvironmentController.java:55)
at org.springframework.cloud.config.server.EnvironmentController.master(EnvironmentController.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:288)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Spring Cloud从Cloud Foundry应用程序中使用通用REST服务.
此服务使用Spring Boot创建,如下所示:
package com.something;
@RestController
public class DemoServiceController {
@RequestMapping("/sayHi")
public String sayHi() {
return "Hello!";
}
}
Run Code Online (Sandbox Code Playgroud)
这很好 - 我可以访问http://www.example.com/srv/demo/sayHi并获得"你好!" 背部.
接下来,我使用CF-CLI创建了一个用户提供的服务实例,并将其绑定到我的应用程序.我现在可以看到绑定的服务了VCAP_SERVICES.
cf cups my-demo-service -p '{"url":"http://www.example.com/srv/demo/"}'
cf bs my-demo-app my-demo-service
Run Code Online (Sandbox Code Playgroud)
接下来,描述在这里,我加入这个bean到我的应用程序的Spring配置,用connector-type一套我原来的控制器(我对它的引用以及).
<cloud:service id="myDemoService"
service-name="my-demo-service"
connector-type="com.something.DemoServiceController"
/>
Run Code Online (Sandbox Code Playgroud)
现在,当我自动连接"myDemoService"到我的应用程序时,
@Autowired
private DemoController myDemoService;
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
找不到指定类型的服务.
我已确保包含所有必需的依赖项,包括spring-cloud-spring-service-connector和spring-cloud-cloudfoundry-connector.
这里出了什么问题?我给出了错误的bean参数吗?任何帮助深表感谢.
我有一个使用 Spring 云配置 (--spring.profiles.active=native) 的应用程序,并在同一应用程序中提供一些 html 页面。一切都很好,直到我引入静态资源(src/main/resources/css/bootstrap-switch.css)。对http://localhost:8080/css/bootstrap-switch.css的 URL 调用失败并出现此异常:
{"timestamp":1438114326940,"status":406,"error":"Not Acceptable","exception":"org.springframework.web.HttpMediaTypeNotAcceptableException","message":"Could not find acceptable representation","path":"/css/bootstrap-switch.css"}
Run Code Online (Sandbox Code Playgroud)
当我禁用@EnableConfigServer 时,URL 返回 CSS 内容。我使用的是 Spring Cloud Config 版本 1.0.2。
这是我可以重现此问题的极简代码:
@SpringBootApplication
@EnableConfigServer
public class Application {
public static void main(String args[]) {
SpringApplication.run(ApplicationConfiguration.class, args);
}
}
@Configuration
@SpringBootApplication
class ApplicationConfiguration {
@Bean
public TestController testController() {
return new TestController();
}
@Bean
public MvcController mvcController() {
return new MvcController();
}
}
@RestController
class TestController {
@RequestMapping("/test")
@ResponseBody
public String test() {
return "hello …Run Code Online (Sandbox Code Playgroud) 我正在对由 zuul 代理服务支持的简单 spring 云应用程序进行一些压力测试,由于 Zuul 和服务之间的连接陈旧,我们偶尔会遇到管道异常异常。我用不同的配置选项配置了 Zuul,但没有成功:
hystrix:
command:
default:
execution:
isolation:
strategy: THREAD
thread:
timeoutInMilliseconds: 61000
ribbon:
ReadTimeout: 60000
ConnectTimeout: 6000
zuul:
host:
socket-timeout-millis: 60000
connect-timeout-millis: 60000
Run Code Online (Sandbox Code Playgroud)
提前感谢您提供解决此问题的任何线索。例外如下:`
com.netflix.zuul.exception.ZuulException:org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:151) ~[router.jar!/:0.0.1] 处的转发错误org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:114) ~[router.jar!/:0.0.1] at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java :112) ~[zuul-core-1.0.28.jar!/:na]
引起:com.netflix.hystrix.exception.HystrixRuntimeException:query-serviceRibbonCommand 失败且没有可用的回退。在 com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand.java:816) ~[hystrix-core-1.4.0-RC6.jar!/:na] 在 com.netflix.hystrix.AbstractCommand$20.call(AbstractCommand. java:798) ~[hystrix-core-1.4.0-RC6.jar!/:na] at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77) ~[rxjava-1.0.4.jar! /:1.0.4] 在 rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.4.jar!/:1.0.4]
引起:java.net.SocketException: 在 java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_45] 在 java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) ~[na: 1.8.0_45] 在 java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[na:1.8.0_45] 在 org.apache.http.impl.io.AbstractSessionOutputBuffer.flushBuffer(AbstractSessionOutputBuffer.java:159) ~[ httpcore-4.3.3.jar!/:4.3.3] ... 在 rx.internal.operators.OperatorMap$1.onNext(OperatorMap.java:55) ~[rxjava-1.0.4.jar!/:1.0.4 ] 在 com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call(LoadBalancerCommand.java:185) ~[ribbon-loadbalancer-2.0-RC13.jar!/:na] 在 com.netflix.loadbalancer.reactive.LoadBalancerCommand$1.call (LoadBalancerCommand.java:180
我有一个可用的 Spring 云配置服务器,它从 git 存储库提供配置。所有配置都存储在存储库的根目录中。他们被命名为{name}-{profile}.yml.
我已将目录结构更改为 {name}/{profile}.yml
当我curl http://configserver:8888/appname/myprofile配置服务器时,我收到一个 json 响应,但 propertySources 为空。
我的 spring 云服务器配置
spring:
cloud:
config:
server:
git:
uri: http://git@git.host/scm/cas/application-config.git
Run Code Online (Sandbox Code Playgroud) 我正在尝试评估使用Consul进行服务发现,但是对于一个简单的项目,RestTemplate不是自动连线的.使用Spring Cloud Consul 1.0.0.M6和Spring Boot 1.3.3.
查看Consul UI,我可以看到我的"多媒体"服务已注册,如果我在下面的代码中注释掉RestTemplate的使用,我可以看到服务实例信息.
是否支持RestTemplate的自动连接,以便使用1.0.0.M6进行Consul发现?如果是这样,那是分享的榜样吗?
我也有一个非常类似的项目使用Eureka工作正常,我只是将@EnableEurekaClient注释更改为@EnableDiscoveryClient并在bootstrap.properties文件中设置consul主机和端口.在阅读Spring Cloud Consul文档时,功能应该几乎完全相同 - RestTemplate自动连接并准备好在http://>/some/path URL中获取服务.
这是代码:
package com.trta.cps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableDiscoveryClient
public class CpsMultimediaServiceClientApplication implements CommandLineRunner {
@Autowired
DiscoveryClient discoveryClient;
@Autowired
private RestTemplate restTemplate;
public static void main(String[] args) {
new SpringApplicationBuilder(CpsMultimediaServiceClientApplication.class).web(false)
.run(args);
}
@Override
public void run(String... args) throws Exception {
discoveryClient.getServices()
.forEach(System.out::println);
discoveryClient.getInstances("multimedia")
.forEach(System.out::println);
String result = this.restTemplate.getForObject("http://multimedia/v1/multimedia/{guid}/info", String.class, "A3E766B4000000E8199D0CA7000002F2");
System.out.println("Response: " + result);
} …Run Code Online (Sandbox Code Playgroud) 现在,我将伪装与hystrix一起使用,事实证明,回退方法在5秒钟内调用20次后,Circuit将变为Open状态。如何更改此规则。例如,当回退方法在5秒钟内调用50次或以回退回调率调用时,让Circuit状态打开。这是我主要的Java代码。
ConsumerApplication.java
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableCircuitBreaker
@RibbonClients({@RibbonClient(name = "cloud-provider", configuration = CloudProviderConfiguration.class)})
public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
UserFeignClient.java
@FeignClient(name = "cloud-provider", fallback = UserFeignClient.HystrixClientFallback.class)
public interface UserFeignClient {
@RequestMapping("/{id}")
BaseResponse findByIdFeign(@RequestParam("id") Long id);
@RequestMapping("/add")
BaseResponse addUserFeign(UserVo userVo);
@Component
class HystrixClientFallback implements UserFeignClient {
private static final Logger LOGGER = LoggerFactory.getLogger(HystrixClientFallback.class);
@Override
public BaseResponse findByIdFeign(@RequestParam("id") Long id) {
BaseResponse response = new BaseResponse();
response.setMessage("disable!!!!");
return response;
}
@Override
public BaseResponse addUserFeign(UserVo userVo) …Run Code Online (Sandbox Code Playgroud) hystrix spring-cloud spring-cloud-feign spring-cloud-netflix
我正在开发一个使用Spring Boot的微服务,它暴露了REST端点.由于可伸缩性,我必须在不同的端口上运行此服务的多个实例.应用程序的配置是什么,以便它可以注册到eureka并且请求是负载平衡的?我正在使用Spring云配置,Eureka服务器和zuul.
I've disabled the config server health indicator with health.config.enabled=false but that isn't disabling the refreshScope health indicator.
我正在从事Spring Boot + Microservices项目。在该项目中,还开发了"microservices-dashboard"项目。
当我简单地运行此项目时,发现以下错误。我使用spring-boot-starter-parent到<version>2.0.4.RELEASE</version>
错误:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.its.MicroservicesDashboardApplication]; nested exception is java.lang.IllegalStateException: Could not evaluate condition on de.codecentric.boot.admin.config.SpringBootAdminClientAutoConfiguration due to org/springframework/boot/bind/RelaxedPropertyResolver not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:646) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.annotation.ConfigurationClassParser.lambda$processDeferredImportSelectors$2(ConfigurationClassParser.java:566) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at java.util.ArrayList.forEach(Unknown …Run Code Online (Sandbox Code Playgroud) spring-cloud ×10
spring ×6
java ×3
spring-boot ×3
spring-mvc ×2
git ×1
hystrix ×1
netflix-zuul ×1