我有一个父组件,它可以有同一个子组件的多个实例。这里棘手的部分是子组件的实例在初始化时可用,并且基于子组件中的某些逻辑,我使用输出事件发射器从父组件重新生成另一个子组件。但是,在保存时,我只看到了放在 html 模板中的子组件的第一个实例,而不是动态生成的。我确实看到了其他类似的问题,但似乎没有人遇到同样的问题。我在这里缺少什么?
任何帮助将不胜感激。
更新 - 开始
如果有人想玩弄并找到原因,添加了一个plunker来演示问题
https://plnkr.co/edit/FW49ztzsg5uyXF7DtHDY?p=preview
更新 - 结束
父组件
import { Component, OnInit, ViewContainerRef, ViewChild, ComponentFactoryResolver, ViewChildren, QueryList } from '@angular/core';
import { ChildComponent } from './child/child.component';
@Component( {
selector: 'parent-cmp',
entryComponents: [ChildComponent],
template: `
<child-cmp (onSomeSelectionChange)="onSomeSelectionChange($event)"></child-cmp>
<div #childCompSection></div>
<button (click)="save()">Save</button>
`
} )
export class ParentComponent implements OnInit {
@ViewChild( 'childCompSection', { read: ViewContainerRef } ) childCompSection: any;
currentComponentHolder: any;
@ViewChildren( ChildComponent ) childComponents: QueryList<ChildComponent>;
constructor( private resolver: ComponentFactoryResolver ) { }
ngOnInit() {
// …Run Code Online (Sandbox Code Playgroud) 我试图让一个简单的微服务注册到Eureka服务器,然后让Zuul代理到微服务.我得到微服务注册到Eureka服务器.但是,每当我带上Zuul服务时,我都会看到它没有注册到Eureka服务器.每当我尝试路由到微服务时,我得到以下异常:
负载均衡器没有可用于客户端的服务器:microservice
我无法弄清问题在哪里.任何帮助将不胜感激
下面是我对每个组件的Spring Boot类.
微服务组件
MicroserviceApplication.java
@SpringBootApplication(scanBasePackages = { "some.package.controller", "some.package.service" })
@EnableEurekaClient
@EnableJpaRepositories("some.package.repository")
@EntityScan("some.package.entity")
public class MicroserviceApplication {
public static void main(String[] args) {
SpringApplication.run(MicroserviceApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
bootstrap.yml
server:
port: 8090
info:
component: Core Services
spring:
application:
name: microservice
Run Code Online (Sandbox Code Playgroud)
application.yml
eureka:
instance:
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
healthcheck:
enabled: true
lease:
duration: 5
#some other logging and jpa properties below
Run Code Online (Sandbox Code Playgroud)
Eureka服务器组件
EurekaServerApplication.java
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Spring Boot 1.5.2.RELEASE + Camel(Spring Boot Starter)+ ActiveMQ进行非常简单的路由,该路由是从特定队列中读取然后进行记录。但是,好像没有在URL上获取spring.activemq配置,正如我在日志中看到的那样,它试图连接到另一个URL,并且继续连接它,而我的spring boot应用程序从未启动。这些问题基于我在下面提供的配置,该如何执行以下操作:
任何帮助将不胜感激。我确实在stackoverflow上搜索了相关问题,但没有一个给我解决所面临问题的解决方案
我在控制台上看到错误,并且仍然喜欢60-70次尝试和计数。如您所见,骆驼要拾取的代理URL是一些默认的URL,可能是spring默认配置的
Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.
Run Code Online (Sandbox Code Playgroud)
这是我当前的配置/代码:
pom.xml-相关部分
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<!-- Spring Cloud is part of the project where I am configuring camel routes -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId>
<version>2.19.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- I have this as the same project works as a …Run Code Online (Sandbox Code Playgroud)