I just recently updated my project from Spring 2 -> 3 and since then I have had issues connecting to pubsub. In the logs I see an error that reads
"java.io.IOException: Your default credentials were not found. To set up Application Default Credentials for your environment
I can get get rid of the error by setting
ENV GOOGLE_APPLICATION_CREDENTIALS "/app/test.json"
COPY test.json /app/test.json
In the docker file but of course once I deploy it, it no longer works.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>5.2.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
then
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
<exclusions>
<exclusion>
<artifactId>threetenbp</artifactId>
<groupId>org.threeten</groupId>
</exclusion>
<exclusion>
<artifactId>re2j</artifactId>
<groupId>com.google.re2j</groupId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</dependency>
in my application-local.properties
file I add
spring.cloud.gcp.pubsub.emulator-host=localhost:8681
spring.cloud.gcp.project-id=local-project
and in the main application.properties
file
#pubsub
spring.cloud.gcp.project-id=${PP_VARS_PROJECTID:pp-playground}
Reading the docs there isn’t much difference between the spring 2 -> 3 implementation
I also should not need a service account within my dockerfile. GCP Spring integrating should be handling this for me.
Has anyone had this issue when upgrading to Spring 3?