在我的Spring Boot应用程序中,假设我有Java接口:
public interface MyFilter<E extends SomeDataInterface>
Run Code Online (Sandbox Code Playgroud)
(一个很好的例子是Spring的公共接口ApplicationListener <E extends ApplicationEvent>)
我有几个实现,如:
@Component
public class DesignatedFilter1 implements MyFilter<SpecificDataInterface>{...}
@Component
public class DesignatedFilter2 implements MyFilter<SpecificDataInterface>{...}
@Component
public class DesignatedFilter3 implements MyFilter<AnotherSpecificDataInterface>{...}
Run Code Online (Sandbox Code Playgroud)
然后,在某些对象中,我有兴趣利用所有实现MyFilter <SpecificDataInterface> 但不是 MyFilter <AnotherSpecificDataInterface>的过滤器
这会是什么语法?
我有一个像这样编码的Jasmine测试:
it ("should send correct message to server to get data, and correctly set up scope when receiving it", function(){
$httpBackend.when('GET', 'https://localhost:44300/api/projectconfiguration/12').respond(fakedDtoBase);
$routeParams.projectId=fakeId; // user asks for editing project
scope.$apply(function(){
var controller=controllerToTest(); // so controller gets data when it is created
});
expect(scope.projectData).toEqual(fakedDtoBase);
});
Run Code Online (Sandbox Code Playgroud)
它有点工作,但我收到错误:
Error: Unexpected request: GET views/core/main/main.html
No more request expected
at $httpBackend (C:/SVN/src/ClientApp/client/bower_components/angular-mocks/angular-mocks.js:1207:9)
at sendReq (C:/SVN/src/ClientApp/client/bower_components/angular/angular.js:7800:9)
at $http.serverRequest (C:/SVN/src/ClientApp/client/bower_components/angular/angular.js:7534:16)
(more stack trace)....
Run Code Online (Sandbox Code Playgroud)
我意识到我可以嘲笑其他所有电话.但是,让我说我不关心我的测试想要加载什么,因为它可能会调用其他一些东西.我怎样才能确保所有其他请求只是"无声地发生",也许只为其他一切提供一个虚拟响应?
我想了解convertAndSendToUser如何在Spring SockJS + Websocket框架中工作.
在客户端,我们将连接为
stompClient.connect(login, password, callback())
Run Code Online (Sandbox Code Playgroud)
这将导致连接请求与登录和密码的"Stomp凭证",例如,如果我们处理SessionConnectEvent http://www.sergialmar.com/2014/03/detect-websocket-connects-and-disconnects-in -spring-4 /
但我仍然不清楚这是否是服务器端向队列发送操作的"用户":
simpMessagingTemplate.convertAndSendToUser(username, "/queue/reply", message);
Run Code Online (Sandbox Code Playgroud)
我能得到的最接近的是阅读这个帖子向Spring Websocket上的特定用户发送消息,由Thanh Nguyen Van回答,但目前还不清楚.
基本上我需要做的是订阅一些客户端到同一主题,但在服务器上,发送不同的数据.客户可以提供用户标识符.
我试图从角度控制器调用模态对话框.这个例子非常简单,距离非常简单.我有代码如
$modal.open({
template: '<div class="modal-body">Choose current project<button class="btn btn-primary" ng-click="ok()">OK</button> <button class="btn btn-warning" ng-click="cancel()">Cancel</button></div>',
controller: ModalChooseProjectCtrl
});
Run Code Online (Sandbox Code Playgroud)
控制功能声明为
var ModalChooseProjectCtrl = function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close($scope.chosenProject);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
Run Code Online (Sandbox Code Playgroud)
它是从一个属于div的控制器函数调用的,它包含bootstrap的navbar.
问题:当我调用具有$ modal.open调用的函数时,会显示错误
Error: [$compile:tplrt] Template for directive 'modalBackdrop' must have exactly one root element. template/modal/backdrop.html
http://errors.angularjs.org/1.2.15-build.2378+sha.9335378/$compile/tplrt?p0=modalBackdrop&p1=template%2Fmodal%2Fbackdrop.html
Error: [$compile:tplrt] Template for directive 'modalWindow' must have exactly one root element. template/modal/window.html
http://errors.angularjs.org/1.2.15-build.2378+sha.9335378/$compile/tplrt?p0=modalWindow&p1=template%2Fmodal%2Fwindow.html
Run Code Online (Sandbox Code Playgroud)
这些错误说模板,可以这么说,mut包含在一个html根元素中,这从模板中可以明显看出来.另外,在调用之后,我看到代码中出现了以下元素
<div modal-backdrop="" class="ng-scope"></div>
<div modal-window="" index="0" animate="animate" class="ng-scope"></div>
Run Code Online (Sandbox Code Playgroud)
如果我进一步点击,代码中会出现更多的模态窗口.但屏幕只是跳跃而没有任何反应,我没有得到我的模态对话框.在Plunker中,对话框的调用代码显示它很好(http://plnkr.co/edit/VJ1Kick7QWE3X0bL6gtw,但它只是基本的调用例程.)
当用户导航离开或重新加载页面时,我想在我的角度应用程序中检测到.
应用程序(使用一些登录过程)应该区分它被重新加载,因此用户不会丢失他的身份验证数据,应用程序应该能够从localStorage恢复必要的信息.
请提供一些"处理"浏览器重新加载/导航的最佳技巧.
我绘制了一些d3.js元素,例如:
// draw rectangle
svg.selectAll(".rect").append("rect")
.attr("y", 10)
.attr("x", 10)
.attr("height", 5)
.attr("width", 5)
.on("contextmenu", function (d, i) {
// react on right-clicking
});
Run Code Online (Sandbox Code Playgroud)
它工作正常,但也打开浏览器的上下文菜单.我怎么能防止这种情况发生?
我在Spring Boot应用程序上运行“渐变测试”时遇到问题,因为我看到GC调用的次数过多,并且由于积极的GC工作导致的延迟而导致测试失败。
我怎样才能告诉gradle在测试阶段或一般情况下使用JVM允许的更多堆内存?
我在ASP.NET webapi项目中使用Swashbuckle 5并使用所有默认设置.它序列化我的方法的输出,以显示回复的模式.我收到的文档看起来像这样:
Response Class (Status 200)
Model Model Schema
[
{
"<Key>k__BackingField": "string",
"<Value>k__BackingField": "string",
"<Id>k__BackingField": 0
}
]
Run Code Online (Sandbox Code Playgroud)
这是通过遵循C#代码生成的
/// <summary>
/// Fetches all system configuration items
/// </summary>
/// <returns>List of <see cref="SystemConfigurationDto" /> items</returns>
public IList<SystemConfigurationDto> GetAllSystemConfigurationItems()
{
var result = CommandProcessor.ProcessCommand(new SystemConfigurationQueryCommand()) as SystemConfigurationQueryCommandResponse;
return result.Results.ToList();
}
Run Code Online (Sandbox Code Playgroud)
其中result.Results基本上是一个标准的对象列表,每个对象包含这些键/值/ id字段.我在这里阅读https://conficient.wordpress.com/2014/05/22/getting-rid-of-k__backingfield-in-serialization/ [serializable]属性可能会影响这个但我不愿意摆脱它属性,如果可能的话.是否有任何配方来调整此序列化工件?
有没有澄清,如果我使用"简单代理",Spring Websocket + SockJS的/ topic,/ queue等之间有什么区别?例如,这里向Spring Websocket上的特定用户发送消息:当您的客户端订阅以/ user /开头的频道时,例如:/ user/queue/reply,您的服务器实例将订阅名为queue/reply-user的队列[会话ID]
我想以一种明确的方式理解这种转换背后的逻辑.
我需要将我的angular $ resources连接到自签名的https web api.如果我试着直接这样做,我会收到诸如此类的消息
OPTIONS https://address/api/authentication net::ERR_INSECURE_RESPONSE
Run Code Online (Sandbox Code Playgroud)
有没有办法克服此错误,通过任何方式指定此特定连接是可信的?
angularjs ×4
java ×3
javascript ×3
spring ×3
sockjs ×2
stomp ×2
autowired ×1
build.gradle ×1
c# ×1
d3.js ×1
gradle ×1
jasmine ×1
jvm ×1
karma-runner ×1
spring-boot ×1
ssl ×1
swagger ×1
swashbuckle ×1