从spring doc,我看到我们可以将peer eureka服务器放在一起,所以对于Eureka1,在application.yml中,我可以:
spring:
profiles: peer1
eureka:
instance:
hostname: peer1
client:
serviceUrl:
defaultZone: http://peer2/eureka/
Run Code Online (Sandbox Code Playgroud)
在Eureka Server 2中,我可以:
spring:
profiles: peer2
eureka:
instance:
hostname: peer2
client:
serviceUrl:
defaultZone: http://peer1/eureka/
Run Code Online (Sandbox Code Playgroud)
现在这两个eureka服务器互相认识,这很好.但是,现在在配置客户端时,当他们再次注册Eureka时,该怎么做?
在我的客户端应用程序中,我有:
eureka:
instance:
hostname: ${host.instance.name:localhost}
nonSecurePort: ${host.instance.port:8080}
leaseRenewalIntervalInSeconds: 5 #default is 30, recommended to keep default
metadataMap:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
serviceUrl:
defaultZone: http://(eurekaServerHost):8761/eureka/
server:
port: ${host.instance.port:8080}
Run Code Online (Sandbox Code Playgroud)
所以现在我的问题是我应该在客户端application.yml中使用peer1或peer2作为EurekaServerHost吗?
谢谢
我正在使用jest来测试我的reactJS组件.在我的reactJS组件中,我需要使用jquery UI,所以我在组件中添加了这个:
var jQuery = require('jquery');
require('jquery-ui/ui/core');
require('jquery-ui/ui/draggable');
require('jquery-ui/ui/resizable');
Run Code Online (Sandbox Code Playgroud)
它工作得很好.但是,现在,我需要使用jest进行测试,但是当我将组件加载到testutils中时,我立即遇到了这个问题,
Test suite failed to run
ReferenceError: jQuery is not defined
Run Code Online (Sandbox Code Playgroud)
如果你在你的应用程序中使用jQuery,有没有人遇到过这个问题?
谢谢
我现在使用反应JEST来测试代码.如果一个组件是单个的,而不是导入任何其他组件,"npm test"运行顺利,现在,我想要一起测试多个组件,我立即得到了这个错误:
SyntaxError: Unexpected token .
Run Code Online (Sandbox Code Playgroud)
似乎只要反应是导入别的东西,比如这个:
require( './style/fixed-data-table.css' );
require( './style/jnpr-datatable.scss' );
Run Code Online (Sandbox Code Playgroud)
然后使用jest抛出意外的标记"." 错误.
我的设置一定有问题,但在哪里?我的Package.json包含:
"jest": {
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react/",
"<rootDir>/node_modules/react-dom/",
"<rootDir>/node_modules/react-addons-test-utils/"
]
}
Run Code Online (Sandbox Code Playgroud)
而.babelrc已经在根目录中了.还包括babel-jest.谢谢
我为feignClients启用了我的spring cloud,如下所示:
@Configuration
@EnableAutoConfiguration
@RestController
@EnableEurekaClient
@EnableCircuitBreaker
@EnableFeignClients
public class SpringCloudConfigClientApplication {
}
Run Code Online (Sandbox Code Playgroud)
但是当我添加enableFeignClients时,我在编译期间遇到了这个错误,
java.lang.NoClassDefFoundError: feign/Logger
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getDeclaredMethods(Class.java:1962)
Run Code Online (Sandbox Code Playgroud)
我的POM是
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>1.0.0.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.SpringCloudConfigClientApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
为了解决假装记录器问题,我需要将哪些其他依赖项添加到POM中?
谢谢
谢谢@spencergibb,基于你的建议,它在我改变我的pom之后起作用了.现在我有另一个使用FeignClient的问题.请看下面:
@Autowired
StoreClient storeClient;
@RequestMapping("/stores")
public List<Store> stores() {
return storeClient.getStores();
}
Run Code Online (Sandbox Code Playgroud)
和界面是:
@FeignClient("store")
public interface StoreClient {
@RequestMapping(method = RequestMethod.GET, value …
Run Code Online (Sandbox Code Playgroud) 我遇到了这个问题真的很头疼,几乎把我的头发拉起来,但仍然无法解决。我希望 docker image 在我启动时自动启动,所以我开始使用入口点,但总是失败。
这是我通常用来启动我的应用程序的命令:
cd /opt/path ./start.sh -l dev -ssl false -srv api
我现在想在 docker 启动时自动运行这个命令。
我在 docker 文件中使用了这个:
WORKDIR /opt/ngcsc
ENTRYPOINT ["start.sh","-l","kubstaging","-ssl", "false", "-srv", "api"]
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
docker: Error response from daemon: oci runtime error: exec: "start.sh": executable file not found in $PATH.
Run Code Online (Sandbox Code Playgroud)
但是如果我改成绝对路径:
入口点 ["/opt/ngcsc/start.sh","-l","kubstaging","-ssl", "false", "-srv", "api"]
在我运行 docker run image 之后
我有:
standard_init_linux.go:175: exec user process caused "exec format error"
Run Code Online (Sandbox Code Playgroud)
这真的是一个大问题,我用谷歌搜索了很多,没有任何效果。你能帮我告诉我该怎么做吗?
谢谢
我关注此链接:http: //cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_client_side_usage
我一次又一次地测试了这个并没有看到Spring云客户端正在从云服务器加载配置,请帮助看看错误在哪里:
POM:
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
应用:
@Configuration
@EnableAutoConfiguration
@RestController
public class ConfigclientApplication {
@Value("${spring.cloud.config.uri}")
String url;
@Value("${production.host}")
String host;
@RequestMapping("/")
public String home() {
return "Host is => " + this.host ;
}
public static void main(String[] args) {
SpringApplication.run(ConfigclientApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
bootstrap.properties:spring.cloud.config.uri = http:// localhost:8888
配置服务器很好: http:// localhost:8888/spirent/default
{ "名称": "思博伦", "简档":[ "默认"], "标签": "主", "propertySources":[{ "名称": "类路径:/spirent.yml", "源": { "production.host": "服务器1", "production.port":9999, "production.value1":12345 "test.host": "server2.com", "test.port":4444,"测试.值 …
我现在正在阅读angular4 doc,并注意到,有一个文件夹,环境,并且在其下有多个环境文件,例如environment.ts,environment.prod.ts,如果我们使用env = prod构建,那么prod将使用环境变量.现在我有一个问题,如何从代码中获取环境变量?我搜索了很多文档,没有提到这一点.谁能帮忙告诉我如何获取环境变量值?谢谢
我可以问一下webpack dev server config是否有类似的配置:
devServer : {
historyApiFallback : true,
stats : 'minimal',
contentBase: helpers.root('../src/static'),
}
Run Code Online (Sandbox Code Playgroud)
我想从静态目录提供静态文件,就像webpack开发服务器如何提供文件一样.谢谢
我有一个问题,也许很简单,但我找不到解决方案.
我正在使用spring boot并在代码中添加了一些注释,如下所示:
@EnableEurekaClient
@SpringBootApplication
@EnableCaching
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
但是在其他一些环境中,例如,在生产环境中,我们想要删除EurekaClient,但我不想手动为每个环境手动删除它,相反,我想使用环境变量或命令行参数来控制行为.我想这样做:
@EnableEurekaClient(Enabled = {EnableEureka})
@SpringBootApplication
@EnableCaching
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我可以轻松启动此应用程序而无需触及代码.
任何人都可以告诉我这是否可能?如果是这样,我该怎么办?
谢谢
我有一个关于如何使 SSE 在多个服务器环境中工作的问题。
在 UI 中,有两个步骤:
1. source = new EventSource('http://localhost:3000/stream');
source.addEventListener('open', function(e) {
$("#state").text("Connected")
}, false);
Run Code Online (Sandbox Code Playgroud)
UI 中的用户可以发布到 api 以更新数据
用户发布到 api 后,服务器将事件发送到 UI 以更新 UI
在一个服务器环境中,这工作得很好,完全没有问题。
但是在多服务器实例环境中,这将不起作用。例如,我有两个服务器实例,UI订阅了服务器1,然后服务器1记住了连接,但是数据更新来自服务器2,当数据发生变化时,服务器2中的SSE没有连接。然后在这个senario,服务器 2 如何将 SSE 发送到 UI?
为了让SSE在多服务器环境下工作,我们是否需要采取任何保存方案来保存连接信息,以便任何服务器实例都可以准确地将SSE发送到UI?
让我再澄清一下:是的,服务 1 和服务 2 都在负载均衡器之后,它们不必具有相同的 URL。UI 是纯前端应用程序,甚至可以是移动应用程序。那么,如果 UI 正在向 server1 的 LB 发送一个 eventSource 请求,那么只有这个实例可以使用这个连接将事件发送回 UI,对吗?但是如果我们有多个服务器 1 实例,这意味着除当前服务器之外的任何服务器 1 实例都不能将事件发送回 UI。我相信这是 SSE 的限制,除非连接可以在所有实例之间共享。但是如何。
谢谢
spring-cloud ×3
angular ×2
babel-jest ×2
jestjs ×2
reactjs ×2
spring ×2
cloud ×1
config ×1
docker ×1
eventsource ×1
java ×1
spring-boot ×1