小编Man*_*ark的帖子

Angular 2路由器 - 从代码命名路由器出口导航

使用@ angular/router":"3.4.7".

这里提出的解决方案不再适用.

      /**
        The ProductComponent depending on the url displays one of two info 
         components rendered in a named outlet called 'productOutlet'.
       */
        @Component({
          selector: 'product',
          template: 
          ` <router-outlet></router-outlet>
            <router-outlet name="productOutlet"></router-outlet>
          `
        })
        export class ProductComponent{
         }
Run Code Online (Sandbox Code Playgroud)
@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild([
          {
            path: 'product',
            component: ProductComponent,
            children: [
              {
                path: '',
                component: ProductOverviewComponent,
                outlet: 'productOutlet'},
              {
                path: 'details',
                component: ProductDetailsComponent,
                outlet: 'productOutlet' }
            ]
          }
      ]

    )],
  declarations: [
    ProductComponent,
    ProductHeaderComponent,
    ProductOverviewComponent,
    ProductDetailsComponent
  exports: [
    ProductComponent,
    ProductHeaderComponent, …
Run Code Online (Sandbox Code Playgroud)

angular2-routing router-outlet

7
推荐指数
2
解决办法
9167
查看次数

Java的.通过此运算符访问实例变量值

我需要有人帮助这个小代码片段; 为什么输出:b 3而不是b 13如预期的那样?

public class Foo{ 
    int a = 3;
    public void addFive() { a+=5; System.out.println("f");}  
}

class Bar extends Foo{
int a = 8;
public void addFive() { this.a+=5; System.out.println("b");}  

public static void main(String[] args) {
    Foo f = new Bar();
    f.addFive();
    System.out.println(f.a);// why b 3 and not b 13 ??
    }
}
Run Code Online (Sandbox Code Playgroud)

java

4
推荐指数
1
解决办法
1006
查看次数

在overriden方法中删除throws,编译器在调用时需要try/catch块

我有一个子类,我重写继承的父方法:我从方法声明中删除throws子句.

现在,使用多态,我的实例的运行时类型应该确定方法实现; 然而,当我尝试编译时,编译器抱怨并想要一个围绕方法调用的try/catch块,就像调用超类方法而不是子类版本一样?

我知道我可以删除throws声明或缩小已检查的异常,这可以在覆盖时抛出.为什么这仍然抛出异常?

class A{
    void foo()throws Exception{throw new Exception();}
}    

class SubB extends A{
    @Override
    void foo(){  System.out.println("B");  
}

public static void main(String[] args) {
    A a = new SubB();
    a.foo(); //compiler reports: unhandled exception type Exception 
}
Run Code Online (Sandbox Code Playgroud)

java

3
推荐指数
1
解决办法
1327
查看次数

当侦听器使用消息时,从 RabbitMQ 中删除消息。无法确定 ReplyTo 消息异常

使用SpringBoot。

我创建了一个 TopicExchange,它接受消息并根据消息中存在的routingKey 将它们定向到两个队列。

消息通过以下方式发送:

rabbitTemplate.convertAndSend('in-out-topic', 'inbound.queue.route.key', payload)
Run Code Online (Sandbox Code Playgroud)

收到消息:

 @RabbitListener(queues = "inbound-queue")
  def onInboundMessage(def message) {
    try {
      log.debug("Received inbound message: ${message.messageId} on inbound queue listener", message)

    } catch (Exception ex) {
      log.error("Inbound message exception: ${ex.getMessage()}")
      return;
    }
    return message.payload
  }
Run Code Online (Sandbox Code Playgroud)

但是当我的侦听器(消费者)收到消息时,我收到以下异常:

org.springframework.amqp.AmqpException: Cannot determine ReplyTo message property value: Request message does not contain reply-to property, and no default response Exchange was set.
Run Code Online (Sandbox Code Playgroud)
  • 我应该通过 RabbitMQ 仪表板创建虚拟响应交换吗?
  • 对不存在的replyTo属性进行硬编码?
  • 以某种方式配置现有的 topicExchange 或 Queues?

我只是希望消息在被消息侦听器使用时从相应的队列中删除。

rabbitmq spring-amqp

2
推荐指数
1
解决办法
3836
查看次数