我使用docker compose来运行我所有的微服务.对于每项服务,我给它一个简短的主机名.
version: '2'
services:
config:
image: springbox-config-server
restart: always
ports:
- "8890:8890"
discovery:
image: springbox-eureka
restart: always
ports:
- "8763:8763"
Run Code Online (Sandbox Code Playgroud)
因此,在我的微服务中,我必须使用其短主机名来定位配置服务器.
spring:
application:
name: myservice
cloud:
config:
uri: http://config:8890
fail-fast: true
Run Code Online (Sandbox Code Playgroud)
但是,当我在没有docker的IDE中本地运行它们时,无法解析短主机名.
所以我正在寻找一种解决方案,根据我的环境定位不同的配置服务器.
如上所述,我的项目中的依赖关系:树目标抱怨已经在其父pom的依赖关系管理部分中声明的依赖关系缺少依赖关系版本.请注意,相关的依赖项是新的,只是在管理部分添加.
我在typescript中创建了一个关于向量的lib.我的第一次测试失败:).
它与TypeScript/JavaScript中的对象相等有关,但我找不到让测试变为绿色的方法.在typescript的官方文档http://www.typescriptlang.org/Handbook#classes中没有提到对象相等.
有人可以帮我一把吗?
这是源代码.
class Vector {
x: number;
y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
add(that: Vector) {
return new Vector(this.x + that.x, this.y + that.y);
}
}
export = Vector;
Run Code Online (Sandbox Code Playgroud)
然后我对这个课进行了单元测试,如下所示
var Vector = require("../lib/vector")
describe("vector", function () {
it("should add another vector", function () {
var v1 = new Vector(1, 1);
var v2 = new Vector(2, 3);
expect(v1.add(v2)).toEqual(new Vector(3, 4));
});
});
Run Code Online (Sandbox Code Playgroud)
执行时获得以下错误
Failures:
1) vector should add …Run Code Online (Sandbox Code Playgroud) 我对android很新,并试图理解bundle是如何工作的.
我被以下单元测试阻止了.有人可以解释一下它失败的原因吗?
@Test
public void testBundle() throws Exception {
Bundle bundle = new Bundle();
String key = "hello";
String value = "world";
bundle.putString(key, value);
Assert.assertEquals(value, bundle.getString(key));
}
junit.framework.ComparisonFailure:
Expected :world
Actual :null
Run Code Online (Sandbox Code Playgroud)