我定义了两个类,它们都包含对另一个对象的引用.它们看起来与此类似(这是简化的;在我的真实域模型中,A类包含B的列表,每个B都有一个返回父A的引用):
public class A {
public B b;
public String bKey;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((b == null) ? 0 : b.hashCode());
result = prime * result + ((bKey == null) ? 0 : bKey.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof A))
return false;
A other …Run Code Online (Sandbox Code Playgroud) 所以2013年4月1日xkcd 外部性网络漫画以Skein 1024 1024哈希破坏比赛为特色.我假设这必须只是一个蛮力的努力,随机字符串被哈希以努力匹配兰德尔的发布哈希?它是否正确?
此外,我对Skein哈希理论的了解实际上并不存在,但作为一个中等程度的程序员,我能够在1024 1024模式下使用一些输入字符串在本地下载和运行SkeinFish(C#)和Maarten Bodewes Skein实现(Java).但是,它们给出的哈希值与xkcd为相同输入返回的哈希值不同.这可能是一个非常天真的问题,但不同的Skein实现会给出不同的哈希值吗?什么Skein实现是xkcd使用的?
谢谢你赦免我的无知!
如何设置我的WPF数据网格以对多个列进行排序,类似于具有两个可排序的列,单击第一列的标题进行主要排序,然后单击SHIFT点击第二列的标题进行二次排序.我希望当用户点击第一列的标题时自动发生多列排序,而不必在第二列标题上单击SHIFT.有没有办法在xaml中完全执行此操作?如果不是,我怎么能在后面的代码中执行此操作?目前使用VB.Net但如果你有一个C#片段是可以接受的.谢谢!
我正在用Java编写一个简单的客户端,以允许可重用使用通过RESTful API访问的专有病毒扫描软件.要上传用于扫描API的文件,需要使用POSTfor Connect,然后使用POSTfor将文件发布到服务器.在对Connect的响应中,POST服务器设置了cookie,后者需要在POST发布文件时使用.我目前正在RestTemplate我的客户端使用Spring .
我的问题是如何访问响应中的cookie以便随后转发回服务器POST?我可以看到它们存在于返回的标题中,但是没有方法ResponseEntity可以访问它们.
我有一个客户端需要将大量的大型json文件POST到服务器.我已经能够通过将每个文件读入内存并使用RestTemplate发布整个文件来实现它.但是,客户端快速耗尽处理大型json文件的内存.我想切换到流式方法,但无法弄清楚如何正确使用RestInmplate的FileInputStream.我发现了这个问题,并使用了接受的答案中给出的代码,但我仍然看到内存使用和OutOfMemory异常使我相信它不是流式传输文件,但仍然完全将它们读入内存.我究竟做错了什么?这是我目前的情况:
final InputStream fis = ApplicationStore.class.getResourceAsStream(path);
final RequestCallback requestCallback = new RequestCallback() {
@Override
public void doWithRequest(final ClientHttpRequest request) throws IOException {
request.getHeaders().add("Content-type", "application/json");
IOUtils.copy(fis, request.getBody());
}
};
final RestTemplate restTemplate = new RestTemplate();
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setBufferRequestBody(false);
restTemplate.setRequestFactory(requestFactory);
final HttpMessageConverterExtractor<String> responseExtractor =
new HttpMessageConverterExtractor<String>(String.class, restTemplate.getMessageConverters());
restTemplate.execute("http://" + host + ":8080/upads-data-fabric" + "/ruleset", httpMethod, requestCallback, responseExtractor);
Run Code Online (Sandbox Code Playgroud) 我按照这里的说明在 JDK v1.6.0_31之上正确安装了最新的JAX-WS版本(2.2.6)(即将JAX-WS发行版中的jaxws-api.jar和jaxb-api.jar复制到我的$ {JAVA_HOME}/lib/endorsed目录).从Eclipse内部我可以正确运行wsimport ant任务,生成的代码在以下注释中给出了一个版本标记:
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.6b21
* Generated source version: 2.2
*
*/
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是生成的客户端代码显示错误导致我相信编译器仍在使用JAX-WS版本2.1:
The constructor Service(URL, QName, WebServiceFeature[]) is undefined
Run Code Online (Sandbox Code Playgroud)
和
The attribute required is undefined for the annotation type XmlElementRef
Run Code Online (Sandbox Code Playgroud)
我尝试在启动Eclipse时显式设置-Djava.endorsed.dir arg,我也尝试在Eclipse-> Preferences-> Java-> InstalledJREs下设置这个arg,但这些都没有帮助.我的wsimport ant任务类路径被定义为查看JAX-WS 2.2.6 jar.我也试过设置我的项目构建路径来拉入2.2.6罐子.似乎没什么用.我错过了什么吗?
在我读过的一本书中,XML配置的优先级高于注释配置.
但是没有任何例子.
你能举例说明一下吗?
我写这个测试类:
@ContextConfiguration(locations = { "classpath:/test/BeanConfig.xml" })
public class CandidateControllerTest {
@Mock(name = "candidateService")
private CandidateService candidateService;
@InjectMocks
private CandidateMenuController candidateMenuController = new CandidateMenuController();
@Autowired
WebApplicationContext wac;
MockMvc mockMvc;
@Before
public void before() {
mockMvc = MockMvcBuilders.webApplicationContextSetup(wac).build();
}
}
Run Code Online (Sandbox Code Playgroud)
但:
代码执行后,我看到下一个跟踪:
java.lang.IllegalArgumentException: WebApplicationContext is required
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.test.web.server.setup.InitializedContextMockMvcBuilder.<init>(InitializedContextMockMvcBuilder.java:39)
at org.springframework.test.web.server.setup.MockMvcBuilders.webApplicationContextSetup(MockMvcBuilders.java:73)
at controllers.CandidateControllerTest.before(CandidateControllerTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序通过休眠加载对象,然后将这些对象作为分离的对象传递给另一个层.对这些对象的任何更改都会发送回hibernate层,我会调用saveOrUpdate()这些对象.
saveOrUpdate()如果我在调用之前只是从集合中删除子对象,那么hibernate是否会删除传入对象中集合中包含的一对多关系子对象saveOrUpdate()?
如果没有,那么通常如何在使用分离对象的hibernate应用程序中完成?
我知道可以在早期版本的Spring MVC中使用自定义过滤器来实现JSONP.此外,此示例描述了通过扩展MappingJacksonHttpMessageConverter类和修改域对象在Spring MVC 3.1中实现JSONP的方法.
除了使用上述方法之外,还有更简单(或传统)的方法来解决Spring MVC 3.2中的JSONP吗?我没有在Spring 3.2文档中看到JSONP.
java ×6
spring ×3
spring-mvc ×3
resttemplate ×2
annotations ×1
c# ×1
cookies ×1
cryptography ×1
datagrid ×1
equals ×1
hash ×1
hashcode ×1
hibernate ×1
http ×1
jax-ws ×1
jsonp ×1
skein ×1
testing ×1
vb.net ×1
wpf ×1