Using generated security password: f9268f9c-f2e6-4e53-a751-632a7005b807
2020-03-03 13:07:44.539 INFO 4824 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#2a92f8c3, org.springframework.security.web.context.SecurityContextPersistenceFilter#412324cd, org.springframework.security.web.header.HeaderWriterFilter#7cf2dd91, org.springframework.security.web.csrf.CsrfFilter#565adf96, org.springframework.security.web.authentication.logout.LogoutFilter#5b3457db, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#b1041fc, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#5e842f37, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#3e06198f, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#574d3e0c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#2b5beb1d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4d02763e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#b273c65, org.springframework.security.web.session.SessionManagementFilter#1f6d3131, org.springframework.security.web.access.ExceptionTranslationFilter#1bf860da, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#11538685]
2020-03-03 13:07:44.612 WARN 4824 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
I didn't include spring security dependencies in POM file, but I'm seeing these lines in my console. Browser prompts for user name and password. How can I fix this?
I don't think so u should be verify or dependency in POM
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
Solved! Eureka server has username password authentication by default. Default username is user, and the password will be generated in the console!
This can be set in application.yml (by profile).
spring:
security:
user:
name: <your user>
password: <your password>
Related
I have problem with properly configuring spring cloud config. I have dependencies
<spring.cloud.version>2021.0.3</spring.cloud.version>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
Boostrap.yml
spring:
application.name: myapp
profiles:
active: dev
config:
import: optional:configserver:http://ip:8888
cloud:
config:
enabled: true
username: admin
password: secret
Now when my application starts it loads config twice. The first load is by class ConfigServicePropertySourceLocator and is without expected profile. The second is by ConfigServerConfigDataLoader and this time it is with proper profile. It seems that the configs loaded during first load takes precedence and my application does not start.
12:32:54 [ConfigServicePropertySourceLocator:241] - Fetching config from server at : http://ip:8888
12:32:54 [ConfigServicePropertySourceLocator:165] - Located environment: name=myapp, profiles=[default], label=null, version=7d2bc5d68acd8fcca65f34f2074b1860f36e19c6, state=null
12:32:54 [MyApplication:646] - The following 1 profile is active: "dev"
12:32:54 [ConfigServerConfigDataLoader:255] - Fetching config from server at : http://ip:8888
12:32:54 [ConfigServerConfigDataLoader:255] - Located environment: name=myapp, profiles=[dev], label=null, version=7d2bc5d68acd8fcca65f34f2074b1860f36e19c6, state=null
Providing profile using param -Dspring.profiles.active=dev does not help. How to configure profile that can be read by boostrap?
Add file resources -> bootstrap.properties
spring.application.name=myapp
spring.profiles.active=dev
# ip and port of the config server
spring.cloud.config.uri=http://localhost:8888
I'm trying to connect my App Engine application (in Java Spring Boot) with a Cloud SQL database. Deployment is working and app start but block on Connection to Cloud SQL :
main] c.g.cloud.sql.core.CoreSocketFactory : First Cloud SQL connection, generating RSA key pair.
main] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [test-api:europe-west1:test-db] via SSL socket.
// Nothing happens after that !
What I do ?
1) I create a user on my database with a username and a password (for example postgres and postgres).
2) I add this dependency to my project
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
3) I update application.properties with
# Gcp configuration
spring.cloud.gcp.sql.database-name=test
spring.cloud.gcp.sql.instance-connection-name=test-api:europe-west1:test-db
#Jdbc connection
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.url=jdbc:postgresql://google/test?cloudSqlInstance=test-api:europe-west1:test-db&socketFactory=com.google.cloud.sql.postgres.SocketFactory&useSSL=false&user=postgres&password=postgres
What is the problem ?
The problem is that nothing happens after Connecting to Cloud SQL instance log. (see before)
In the log of launch I can see that informations :
main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.19]
main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 11980 ms
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : Default POSTGRESQL JdbcUrl provider. Connecting to jdbc:postgresql://google/test?socketFactory=com.google.cloud.sql.postgres.SocketFactory&socketFactoryArg=test-api:europe-west1:test-db&useSSL=false with driver org.postgresql.Driver
main] o.s.c.g.a.s.GcpCloudSqlAutoConfiguration : spring.datasource.url is specified. Not using generated Cloud SQL configuration
main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
main] c.g.cloud.sql.core.CoreSocketFactory : First Cloud SQL connection, generating RSA key pair.
main] c.g.cloud.sql.core.CoreSocketFactory : Connecting to Cloud SQL instance [test-api:europe-west1:test-db] via SSL socket.
Other curious point is that I specify &useSSL=false but app is connecting via SSL socket according to log.
This sounds very similar to what was happening in github/cloud-sql-jdbc-socket-factory #148. The issue was a dependency conflict, where an outdated version of guava as causing problems. Can you check what version of guava you have specified?
Also, no need to be concerned about using &useSSL=false - the JDBC SF always uses SSL, so this is intentional.
I am getting the below error
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'rate' in string value "${rate}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]
The spring boot version used is
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
The yml file of server is
server:
port: 9000
spring:
cloud:
config:
server:
git:
uri: https://github.com/kswat/microservices
search-paths:
- 'station*'
The server starts fine and at port 9000.
Client project:
Using same version of spring boot.
spring:
application:
name: s1rates
profiles:
active: default
cloud:
config:
uri: http://localhost:9000
enabled: true
Controller code:
#RestController
public class RateController {
#Value("${rate}")
String rate;
#RequestMapping("/rate")
public String getRate(){
return rate;
}
}
Is there limitation on port 8888?
why my client starts with looking for 8888
:: Spring Boot :: (v1.4.3.RELEASE)
2017-03-24 13:04:51.348 INFO 1048 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2017-03-24 13:04:52.479 WARN 1048 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/s1rates/default": Connection refused: connect; nested exception is java.net.ConnectException: Connection refused: connect
2017-03-24 13:04:52.483 INFO 1048 --- [ main] c.b.samples.M2ConfigclientApplication : The following profiles are active: default
2017-03-24 13:04:52.518 INFO 1048 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#e84a8e1: startup date [Fri Mar 24 13:04:52 GMT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#70325e14
2017-03-24 13:04:53.492 WARN 1048 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-03-24 13:04:53.657 INFO 1048 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=d17fb23f-878c-3e56-87f0-af48d4c36965
2017-03-24 13:04:53.743 INFO 1048 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$4e824d73] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-24 13:04:54.178 INFO 1048 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-03-24 13:04:54.194 INFO 1048 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
If I use 8888 in config server, then client works cleanly, without exception.
What is 8888 magic and why I have to stick to it? Is this boot version issue or my mistake?
Resolved -
Changed cloud client project application.yml filename to bootstrap.yml
port 9000 of server works
bootstrap.yml gets loaded before application.yml
Very important, the client application name needs to be the same as the properties name in the repository.For example,your config client application name is config-client,then your properties file in your repository should be config-client-dev.properties.Or you will get the Could not resolve placeholder ${xxx} error.
Add the below dependency in your pom.xml file
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
The client application name needs to be the same as the properties name in the repository. For example, your config client application name is config-client, then your properties file in your repository should be config-client-dev.properties. Or you will get the "Could not resolve placeholder ${xxx}" error.
Spring cloud server that uses git as a property source works with the repository in git style, so it can use different branches, and what`s important regarding the question - the changes must be committed for being visible.
The Spring Boot guide says I can get the H2 console but it's not working for me.
http://localhost:8080/h2/ Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Oct 26 12:31:46 BST 2016
There was an unexpected error (type=Not Found, status=404).
No message available
I created an application.properties file as follows
spring.h2.console.enabled=true
spring.h2.console.path=/h2
My project is based on this
The default path /h2-console doesn't work either.
I found another answer where the problem is solved by adding to Application.java:
#Bean
public ServletRegistrationBean h2servletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
registration.addUrlMappings("/h2/*");
return registration;
}
Everything in my application.properties file is ignored. I have tried adding:
spring.datasource.url=jdbc:h2:file:~/portal;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=org.h2.Driver
But the database is still created in memory only.
Check if you set a base path in application.properties.
For example, if you have a setting
server.contextPath=/api
You access the h2 Console under
http://localhost:8080/api/h2-console
Obvious, but that was it for me
Another possible cause for this problem, is if you're using spring security.
In that case, you may want to add a specific permission to the h2-console URL you defined.
For example, for the default h2-console configuration (without a spring.h2.console.path property), you will add this inside your WebSecurityConfigurerAdapter extending class:
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/h2-console/**").permitAll()
.anyRequest().authenticated();
http.headers().frameOptions().sameOrigin();
}
Please also note that line at the end - http.headers().frameOptions().sameOrigin();.
It's needed to prevent a Whitelable page error when logging in to the console.
This is described also here.
Your current location src\main\java\hello\application.properties is the culprit. For 2 reasons.
Non java resources in src\main\java are ignored
only application.properties in the root or config directory or taken into account (by default). (See the reference guide).
The fix is to simply move your application.properties to src\main\resources.
In my case, I just had to remove the tag <scope>runtime</scope> from the h2 dependency as explained in here.
a / is missing before spring.h2.console.path it have to look like :
spring.h2.console.path=/h2
also when you indicate spring.h2.console.path /h2-console is no more available
Regards
I tried h2-console while building my microservice project and fell into the same issue "Whitelabel error page".
I haven't added any security in my project for now but I found the problem for me is solved by removing spring.h2.console.enabled= true from application.properties and adding dependency dev-tools. for me not adding dev-tools also caused the problem so try to add this dependency as well. while of course, you will add h2, actuator, web dependencies.
Try the below in application.properties
spring.h2.console.enabled: true
try to add to application.properties
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
//then
create class SecurityConfig
#Configuration
#EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.authorizeRequests().antMatchers("/").permitAll().and()
.authorizeRequests().antMatchers("/h2-console/**").permitAll();
httpSecurity.csrf().disable();
httpSecurity.headers().frameOptions().disable();
}
}
For me scope=test was the issue as I carelessly copied from https://mvnrepository.com/artifact/com.h2database/h2/1.4.200
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>
And replaced it with
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>runtime</scope>
</dependency>
After this, it should work with default configurations.
I am not using spring security, but you might need to make certain changes accordingly. Please check above answers for that https://stackoverflow.com/a/59729714/7359806
First, make sure to have these dependencies:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Then add these to your application.properties:
##spring.main.web-application-type=none make sure it's commented
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
##server.port=9999 make sure you use default port (8080). In other words, don't specify a server.port
For me - a computer restart fixed it.
Not sure why this would be the cause but perhaps a port was occupied, or the h2 related files were not deployed correctly
make sure you that when the springBoot application is launched, you can see the log lines for Hibernate and H2 are present:
2017-04-22 14:41:03.195 INFO 912 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-04-22 14:41:03.197 INFO 912 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-04-22 14:41:03.199 INFO 912 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-04-22 14:41:03.278 INFO 912 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-04-22 14:41:03.469 INFO 912 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2017-04-22 14:41:03.935 INFO 912 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-04-22 14:41:03.945 INFO 912 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
For this problem, i just add the default string at my application.properties and works.
spring.datasource.url=jdbc:h2:file:~/test
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
Maybe the spring boot dont set this for some reason.
Remove <scope>test</scope> from h2 dependency in pom.xml works in my case.
Don't forget to reinstall and build again after your modification.
<!-- H2 database -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.199</version>
<!-- <scope>test</scope> -->
</dependency>
I used compile otherwise testCompile in the Gradle declaration and was worked fine for me.
Example:
compile group: 'com.h2database', name: 'h2', version: '1.4.200'
If you are having troubles with the program ignoring the application.properties and you are using Eclipse, do the following:
Move the application.properties into the src/main/resources folder, right click on it and click "build path" -> "Add to build path"
Make sure to use> spring.datasource.url=jdbc:h2:mem:testdb as this db is required for h2
I found the same case using Eclipse 4.26.0
Did some of above method and not work. Until in one forum, someone suggest us to add devtools dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
I hope it works for you.
I have some applications getting its configuration from a Spring Cloud Config Server (Brixton.RELEASE) and would like to enable the auto refresh of its properties. I have followed Spring Cloud Config documentation to configure both the server and client apps but, when making changes on the local git files nothing happens.
the default configuration also detects filesystem changes in local git
repositories (the webhook is not used in that case but as soon as you
edit a config file a refresh will be broadcast).
Can anybody point out what could be wrong or where to debug in Spring Cloud's code to check it?
Spring cloud Server Config:
server:
port: 8888
info:
description: Spring Cloud Config Server
spring:
application:
name: config-server
cloud:
config:
server:
git:
uri: file:///C:/Users/myuser/git/config-dev/
Spring Cloud Server pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
Spring Cloud Config Startup logs:
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusInput
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput]
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusOutput
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput]
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel errorChannel
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel]
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel nullChannel
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal]
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648
o.s.c.s.binding.BindableProxyFactory : Binding outputs for :interface org.springframework.cloud.bus.SpringCloudBusClient
o.s.c.s.binding.BindableProxyFactory : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusOutput
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#707ca986: startup date [Fri May 13 10:03:10 CEST 2016]; root of context hierarchy
trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$73faa1d3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
e.m.a.config.ConfigServerApplication : No active profile set, falling back to default profiles: default
s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#1ca610a0: startup date [Fri May 13 10:03:11 CEST 2016]; parent: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#294a6b8e
o.s.c.support.GenericApplicationContext : Refreshing org.springframework.context.support.GenericApplicationContext#6048e26a: startup date [Fri May 13 10:03:11 CEST 2016]; root of context hierarchy
e.m.a.config.ConfigServerApplication : Started ConfigServerApplication in 2.907 seconds (JVM running for 12.366)
o.s.a.r.c.CachingConnectionFactory : Created new connection: SimpleConnection#7bbcf6f0 [delegate=amqp://guest#127.0.0.1:5672/]
o.s.i.endpoint.EventDrivenConsumer : Adding {message-handler:outbound.springCloudBus} as a subscriber to the 'springCloudBusOutput' channel
o.s.integration.channel.DirectChannel : Channel 'config-server:8888.springCloudBusOutput' has 1 subscriber(s).
o.s.i.endpoint.EventDrivenConsumer : started outbound.springCloudBus
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
o.s.i.endpoint.EventDrivenConsumer : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
o.s.i.channel.PublishSubscribeChannel : Channel 'config-server:8888.errorChannel' has 1 subscriber(s).
o.s.i.endpoint.EventDrivenConsumer : started _org.springframework.integration.errorLogger
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147482647
o.s.c.s.binding.BindableProxyFactory : Binding inputs for :interface org.springframework.cloud.bus.SpringCloudBusClient
o.s.c.s.binding.BindableProxyFactory : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusInput
o.s.c.s.b.r.RabbitMessageChannelBinder : declaring queue for inbound: springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg, bound to: springCloudBus
o.s.integration.channel.DirectChannel : Channel 'springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg.bridge' has 1 subscriber(s).
o.s.i.a.i.AmqpInboundChannelAdapter : started inbound.springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg
Client App pom.xml:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
Client App config:
spring:
application:
name: app
cloud:
config:
uri: http://localhost:8888
Client App Startup log:
o.s.b.a.e.m.EndpointHandlerMapping INFO - Mapped "{[/bus/refresh],methods=[POST]}" onto public void org.springframework.cloud.bus.endpoint.RefreshBusEndpoint.refresh(java.lang.String)
...
o.s.i.m.IntegrationMBeanExporter INFO - Registering beans for JMX exposure on startup
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel springCloudBusInput
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput]
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel springCloudBusOutput
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput]
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel nullChannel
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel]
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel errorChannel
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel]
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint]
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal]
o.s.b.a.e.j.EndpointMBeanExporter INFO - Registering beans for JMX exposure on startup
Try to go through this documentation spring-cloud-config-push-notifications and do not forget to install ngrock. Also if you just need to refresh on git commit then you do not even need cloud-bus project just config should be enough. Hope this helps.
You would need a Config server with Spring Cloud Bus and RabbitMQ (or Kafka or Redis) support.
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
...
RabbitMQ with the following exchange:
name: springCloudBus
type: topic
durable: true
autoDelete: false
internal: false
The Config server would send data to the topic once it receives push events from any of Github, Bitbucket or GitLab, via a webhook to http://<config-server>/monitor
And a client application with Config and RabbitMQ libraries:
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
...
Subscribed to the previous exchange to receive messages with the properties that need to be refreshed.
More could be found in my blog at: http://tech.asimio.net/2017/02/02/Refreshable-Configuration-using-Spring-Cloud-Config-Server-Spring-Cloud-Bus-RabbitMQ-and-Git.html with a brief explanation of the configuration, logs and full source code for the Config server and client app.
You need have fallowing dependent in the pom.xml
compile('org.springframework.cloud:spring-cloud-stream-binder-rabbit') - Gradle
if you have hosed you rabbitmq in the another system you need to specify the host file in the application.properties
spring.rabbitmq.host: {{hostname}}