我使用AWS elasticsearch服务(非EC2)设置了elasticsearch服务器.它给了我一个端点https://xxx-xxxxxxxx.us-west-2.es.amazonaws.com/如果我点击这个端点(注意没有指定端口)我可以得到预期的
{
status: 200,
name: "Mastermind",
cluster_name: "xxxx",
version: {
number: "1.5.2",
build_hash: "yyyyyy",
build_timestamp: "2015-04-27T09:21:06Z",
build_snapshot: false,
lucene_version: "4.10.4"
},
tagline: "You Know, for Search"
}
Run Code Online (Sandbox Code Playgroud)
问题是如何通过不带端口号的elasticsearch java客户端获取此信息?我得到的示例代码是
Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300));
Run Code Online (Sandbox Code Playgroud)
如果我使用此代码并将"host1"替换为我的端点,我将得到"NoNodeAvailableException"
ps:我使用的java客户端版本是2.0.0.
编辑 我最终决定选择第三方REST客户端Jest.但Brooks在下面回答的内容也非常有用 - AWS确实将端口80用于http,将443用于https.对我来说阻止者是我猜的防火墙.
Edit2
AWS ES服务文档明确说明:
该服务支持端口80上的HTTP,但不支持TCP传输.
amazon-web-services elasticsearch elasticsearch-java-api amazon-elasticsearch
我正在使用带有许可证的SmartGit6和git 1.9.4.刷新真的很慢,而且通常需要40秒来显示日志.SmartGit2的工作速度非常快.我能做些什么来让它更快?
假设我们有:
<form action="xxx">
<input type="checkbox" id = "checkbox" name="checked" value="1">
<input type="submit">Submit</input>
</form>"
Run Code Online (Sandbox Code Playgroud)
单击提交按钮时,网址应类似于“xxx?checked=1”。在这种情况下,我想向 url 附加另一个参数。我知道使用隐藏值是一种选择,但我们有更直接的方法吗?请建议。谢谢
我正在为一个复杂的弹簧应用程序编写单元测试.我想加载spring上下文以使用定义的bean.我的context.xml位于:
src/main/resources/context.xml
Run Code Online (Sandbox Code Playgroud)
在maven构建之后,context.xml出现在:
target/classes/context.xml
Run Code Online (Sandbox Code Playgroud)
在pom.xml中,我有:(正如所建议的这个帖子)
<resources>
<resource>
<filtering>true</filtering>
<directory>src/test/resources</directory>
<includes>
<include>**/*.properties</include>
</includes>
<excludes>
<exclude>**/*local.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
Run Code Online (Sandbox Code Playgroud)
我试图通过两种方式完成这项工作:
1, Use ApplicationContext
AppliactionContext springContext = new ClassPathXmlApplicationContext("/context.xml");
MyObject myObject = springContext.getBean(myObject.class);
2, Use Annotations
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/context.xml"})
public class myTest{
@Autowired
MyObject myObject;
...
}
Run Code Online (Sandbox Code Playgroud)
但这两种方式都不适合我.错误信息:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) …Run Code Online (Sandbox Code Playgroud) 我正在尝试将facebook登录集成到我的解析应用程序中.我按照解析教程中提到的每一步进行操作.在下面的代码中,我收到编译错误.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
line1: Parse.setApplicationId("xxx", clientKey: "yyy")
line2: PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)
line3: PFAnalytics.trackAppOpenedWithLaunchOptions(launchOptions)
line4: return true
}
Run Code Online (Sandbox Code Playgroud)
在第3行,我收到错误:
可选类型的值'
[NSObject:AnyObject]'未展开; 你的意思是用'!'还是'?'?
如果我使用' !' 手动解开它,因为launchOptions可以是nil,我得到:
致命错误:在展开Optional值时意外发现nil
如果我检查无,我得到:
NSInternalInconsistencyException',原因:'你必须通过调用来初始化PFFacebookUtils+initializeFacebookWithApplicationLaunchOptions
知道怎么解决吗?