我已经实现了一个简单的应用程序来理解spring cloud是如何为客户端配置的。
它只包含两个类:
@SpringBootApplication
public class ClientApplication {
public static void main(String[] args) {
SpringApplication.run(ClientApplication.class, args);
}
}
@RefreshScope
@RestController
public class ExampleController {
@Value("${example.message:none}")
private String message;
@GetMapping("/message")
public String getMessage() {
return this.message;
}
}
server.port = 8080
# Customize the Pub/Sub Topic to be used as the message bus.
spring.cloud.gcp.project-id=spring-samples-269912
spring.cloud.bus.destination=cloud-bus-demo-topic
spring.cloud.config.uri=http://35.202.199.184
spring.cloud.gcp.credentials.location=file:secret.json
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0' // Latest 1.x.x release
}
}
plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'java'
id 'com.google.cloud.tools.jib' version '2.1.0'
}
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.google.cloud.tools.appengine'
group = 'my.config.server'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/milestone/" }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter-bus-pubsub'
implementation 'org.springframework.cloud:spring-cloud-config-client'
}
test {
useJUnitPlatform()
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR1"
mavenBom "org.springframework.cloud:spring-cloud-gcp-dependencies:1.2.1.RELEASE"
}
}
appengine {
deploy { // deploy configuration
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
projectId = 'spring-samples-269912' // delegate to project in gcloud config
version = 'GCLOUD_CONFIG' // delegate to gcloud to generate a version
}
}
jib {
to {
image = "us.gcr.io/spring-samples-269912/config-client-image"
auth {
username = "_json_key"
password = file("secret.json").text
}
}
}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.5.RELEASE)
2020-03-16 16:13:59.255 INFO 8948 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-03-16 16:13:59.995 INFO 8948 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=application, profiles=[default], label=null, version=abd4f2a3e1193705ae692a7217db894772525277, state=null
2020-03-16 16:13:59.995 INFO 8948 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-git://github.com/gredwhite/config-repo-demo.git/application.properties'}]
2020-03-16 16:13:59.999 INFO 8948 --- [ main] my.config.client.ClientApplication : No active profile set, falling back to default profiles: default
2020-03-16 16:14:00.347 INFO 8948 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=30c969b5-0fdd-3bcc-953b-09ef7014e64c
2020-03-16 16:14:00.364 INFO 8948 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2020-03-16 16:14:00.367 INFO 8948 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2020-03-16 16:14:00.370 INFO 8948 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2020-03-16 16:14:00.384 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:00.385 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:00.390 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:00.393 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:00.399 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationChannelResolver' of type [org.springframework.integration.support.channel.BeanFactoryChannelResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:00.399 INFO 8948 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-16 16:14:01.400 INFO 8948 --- [ main] o.s.c.g.core.DefaultCredentialsProvider : Default credentials provider for service account spring-samples-service-account@spring-samples-269912.iam.gserviceaccount.com
2020-03-16 16:14:01.400 INFO 8948 --- [ main] o.s.c.g.core.DefaultCredentialsProvider : Scopes in use by default credentials: [https://www.googleapis.com/auth/pubsub, https://www.googleapis.com/auth/spanner.admin, https://www.googleapis.com/auth/spanner.data, https://www.googleapis.com/auth/datastore, https://www.googleapis.com/auth/sqlservice.admin, https://www.googleapis.com/auth/devstorage.read_only, https://www.googleapis.com/auth/devstorage.read_write, https://www.googleapis.com/auth/cloudruntimeconfig, https://www.googleapis.com/auth/trace.append, https://www.googleapis.com/auth/cloud-platform, https://www.googleapis.com/auth/cloud-vision, https://www.googleapis.com/auth/bigquery]
2020-03-16 16:14:01.401 INFO 8948 --- [ main] o.s.c.g.a.c.GcpContextAutoConfiguration : The default project ID is spring-samples-269912
2020-03-16 16:14:01.409 INFO 8948 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'pubsubPublisherThreadPool'
2020-03-16 16:14:01.411 INFO 8948 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'pubsubSubscriberThreadPool'
2020-03-16 16:14:01.428 INFO 8948 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'pubSubAcknowledgementExecutor'
2020-03-16 16:14:01.811 INFO 8948 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2020-03-16 16:14:01.908 INFO 8948 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel errorChannel
2020-03-16 16:14:01.948 INFO 8948 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusInput
2020-03-16 16:14:01.966 INFO 8948 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusOutput
2020-03-16 16:14:01.972 INFO 8948 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel nullChannel
2020-03-16 16:14:01.981 INFO 8948 --- [ main] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageHandler errorLogger
2020-03-16 16:14:02.000 INFO 8948 --- [ main] o.s.c.s.m.DirectWithAttributesChannel : Channel 'application-1.springCloudBusInput' has 1 subscriber(s).
2020-03-16 16:14:02.001 INFO 8948 --- [ main] o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-03-16 16:14:02.001 INFO 8948 --- [ main] o.s.i.channel.PublishSubscribeChannel : Channel 'application-1.errorChannel' has 1 subscriber(s).
2020-03-16 16:14:02.001 INFO 8948 --- [ main] o.s.i.endpoint.EventDrivenConsumer : started bean '_org.springframework.integration.errorLogger'
2020-03-16 16:14:02.380 INFO 8948 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://35.202.199.184
2020-03-16 16:14:03.015 INFO 8948 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=application, profiles=[default], label=null, version=abd4f2a3e1193705ae692a7217db894772525277, state=null
2020-03-16 16:14:03.015 INFO 8948 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-git://github.com/gredwhite/config-repo-demo.git/application.properties'}]
2020-03-16 16:14:04.268 INFO 8948 --- [ main] o.s.c.s.m.DirectWithAttributesChannel : Channel 'application-1.springCloudBusOutput' has 1 subscriber(s).
2020-03-16 16:14:10.152 INFO 8948 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 1 subscriber(s).
2020-03-16 16:14:10.153 INFO 8948 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 0 subscriber(s).
2020-03-16 16:14:10.153 INFO 8948 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 1 subscriber(s).
2020-03-16 16:14:10.153 INFO 8948 --- [ main] o.s.c.stream.binder.BinderErrorChannel : Channel 'anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 2 subscriber(s).
2020-03-16 16:14:10.179 INFO 8948 --- [ main] .s.c.g.p.i.i.PubSubInboundChannelAdapter : started org.springframework.cloud.gcp.pubsub.integration.inbound.PubSubInboundChannelAdapter@10b67f54
2020-03-16 16:14:10.196 INFO 8948 --- [ main] my.config.client.ClientApplication : Started ClientApplication in 12.181 seconds (JVM running for 13.372)
2020-03-16 16:14:10.201 INFO 8948 --- [extShutdownHook] .s.c.g.p.i.i.PubSubInboundChannelAdapter : stopped org.springframework.cloud.gcp.pubsub.integration.inbound.PubSubInboundChannelAdapter@10b67f54
2020-03-16 16:14:13.941 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors
2020-03-16 16:14:13.990 INFO 8948 --- [extShutdownHook] o.s.c.stream.binder.BinderErrorChannel : Channel 'application-1.anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 1 subscriber(s).
2020-03-16 16:14:13.990 INFO 8948 --- [extShutdownHook] o.s.c.stream.binder.BinderErrorChannel : Channel 'application-1.anonymous.cloud-bus-demo-topic.0c7beefc-5850-4cb5-8b1d-3779305910eb.errors' has 0 subscriber(s).
2020-03-16 16:14:13.991 INFO 8948 --- [extShutdownHook] o.s.i.endpoint.EventDrivenConsumer : Removing {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2020-03-16 16:14:13.991 INFO 8948 --- [extShutdownHook] o.s.i.channel.PublishSubscribeChannel : Channel 'application-1.errorChannel' has 0 subscriber(s).
2020-03-16 16:14:13.991 INFO 8948 --- [extShutdownHook] o.s.i.endpoint.EventDrivenConsumer : stopped bean '_org.springframework.integration.errorLogger'
2020-03-16 16:14:13.991 INFO 8948 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'taskScheduler'
2020-03-16 16:14:13.994 INFO 8948 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'pubSubAcknowledgementExecutor'
2020-03-16 16:14:13.994 INFO 8948 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'pubsubSubscriberThreadPool'
2020-03-16 16:14:13.995 INFO 8948 --- [extShutdownHook] o.s.s.c.ThreadPoolTaskScheduler : Shutting down ExecutorService 'pubsubPublisherThreadPool'
2020-03-16 16:14:13.996 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: bean 'errorChannel'
2020-03-16 16:14:13.996 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: bean 'springCloudBusInput'
2020-03-16 16:14:13.996 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: bean 'springCloudBusOutput'
2020-03-16 16:14:13.996 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: nullChannel
2020-03-16 16:14:13.996 INFO 8948 --- [extShutdownHook] o.s.i.monitor.IntegrationMBeanExporter : Summary on shutdown: bean '_org.springframework.integration.errorLogger.handler' for component '_org.springframework.integration.errorLogger'
我也有同样的问题,通过遵循这里发布的答案,我的问题得到了解决。原因是您没有在项目中添加Spring Starter Web依赖项,因此没有为应用程序创建Web服务器实例,这将使应用程序保持活力,因此在向discovery server注册后,它的工作就完成了,并关闭应用程序。只需在build.gradle文件中添加以下行:-
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
//other dependencies
}
启动客户端 需要启动一个以太坊客户端,当然如果你已经启动了就不需要再次启动。 如果是geth的话这么启动: $ geth --rpcapi personal,db,eth,net,web3 --rpc --rinkeby 如果是Parity启动: $ parity --chain testnet 如果使用Infura客户端提供的免费的云端服务,这么启动: Web3j web3 = Web3j.
客户端跟服务端基本一样,也支持Web Host和Generic host 调用AddClient方法启用客户端 public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(Compatibility
问题内容: 我正在创建一个在任何情况下都无法管理或修改的服务器上运行的Web应用程序。 在该应用程序中,我需要执行对其他服务器的AJAX调用。这将始终被“相同原产地政策”阻止。 其中server01.test.net是Web服务器,而mail.test.net是第二台服务器。 有没有一种方法可以通过任何方式在客户端启用CORS,因为我无法在服务器上添加“ Access-Control-Allow-
当我尝试运行Springboot eureka客户端时,我发现以下运行时异常 组织。springframework。豆。工厂BeanDefinitionStoreException:未能加载bean类:;嵌套的异常是java。lang.IllegalStateException:找到注解@EnableDiscoveryClient,但没有实现。你忘了带开胃菜吗?
当执行客户端重新启动或关闭时,服务器端的所有套接字连接都挂起CLOSE_WAIT。用于将序列化数据发送到XDR流中的XdrAble。池是标准KeyedSocketPool的对象。MAXIMUM_RETRY、MAXIMUM_RETYR_BEFORE_RESET_POOL是为重置池连接而定义的常量。关闭连接时我缺少了什么? 公共RESP调用(REQ request、RESP response、int
环境准备 请参考环境准备 创建工作目录 export FALCON_HOME=/home/work export WORKSPACE=$FALCON_HOME/open-falcon mkdir -p $WORKSPACE 解压二进制包 tar -xzvf open-falcon-v0.2.1.tar.gz -C $WORKSPACE 在一台机器上启动所有的后端组件 首先确认配置文件中数据库账