Version: spring_cloud_dependency_version=Hoxton.SR11
Issue: When using a composite configuration consisting of two git repos, one for storing default settings that are applied for all clients, and a second git configuration that contains an {application} placeholder that is used to match a the configuration settings repo for the application, the basedir setting seems to be ignored. I have tried using both fully qualified paths and relative path values for basedir.
application.yml
spring:
profiles:
active: default,cloud,composite
cloud:
config:
allowOverride: true
overrideNone: true
overrideSystemProperties: false
server:
git:
basedir: ./repo
composite:
-
type: git
uri: ssh://git@myserver.com:7999/projects/{application}-config/
-
type: git
uri: ssh://git@myserver:7999/projects/defaults-config.git
Excerpt from logging output:
...
2021-05-24 15:03:58,381 Mon I [http-nio-8888-exec-1] et.DispatcherServlet [spring-ccs,,,,]-[ ] Completed initialization in 19 ms
--
2021-05-24 15:04:03,240 Mon I [http-nio-8888-exec-1] nvironmentRepository [spring-ccs,,2080b492253f5989,2080b492253f5989,]-[ ] Adding property source: file:/tmp/config-repo-2409999299177514716/application.properties
2021-05-24 15:04:04,057 Mon I [http-nio-8888-exec-2] nvironmentRepository [spring-ccs,,51e7e1a93e8ab7bd,51e7e1a93e8ab7bd,]-[ ] Adding property source: file:/tmp/config-repo-2409999299177514716/application.properties
2021-05-24 15:04:04,859 Mon I [http-nio-8888-exec-4] nvironmentRepository [spring-ccs,,49988e3f97c7d6d0,49988e3f97c7d6d0,]-[ ] Adding property source: file:/tmp/config-repo-2409999299177514716/application.properties
2021-05-24 15:04:06,443 Mon I [http-nio-8888-exec-3] nvironmentRepository [spring-ccs,,43dee3d489e35b90,43dee3d489e35b90,]-[ ] Adding property source: file:/tmp/config-repo-2409999299177514716/application.properties
...
As shown above in the logs, the basedir that is used is still /tmp/config-repo-...... The basedir setting of ./repo is not used. This directory exists, has permissions of 777 and is accessible by the user running the application.
The cloud config server is being run in a Docker container. The logging message "Adding property source: file:/tmp/config-repo-2409999299177514716/application.properties" is continuously being generated roughly every 3 seconds. due to the underlying operating system cleaning out the tmp directory.
With further testing, I found that setting basedir under
composite:
\tgit:
\t\tbasedir: <full_path_to_directory>
actually works, but the unit test
package com.somecompany.cloudconfig;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class GatewayCloudConfigApplicationTests {
@Test
void contextLoads() {
}
}
fails with this error
GatewayCloudConfigApplicationTests > contextLoads() FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:797
Caused by: org.springframework.beans.factory.BeanCreationException at ConstructorResolver.java:655
Caused by: org.springframework.beans.BeanInstantiationException at SimpleInstantiationStrategy.java:185
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at ConstructorResolver.java:797
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException at AutowiredAnnotationBeanPostProcessor.java:723
Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1794
Caused by: java.lang.IllegalStateException at Assert.java:76
Comment From: ryanjbaxter
Please learn how to format code on GitHub.
The error in the unit test doesn't really point to a problem.
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Comment From: ryee98
Closing this issue. I found with additional testing that when the directory specified by basedir was not writable, the contextLoads tests failed.