Search code examples
spring-bootgoogle-cloud-sqlgoogle-cloud-pubsub

Problem with Google cloud SQL and Google pubsub together :Error A database name must be provided


I have a rest application which which talks to google cloud sql and based on some data and I will sent data to pubsub topic. I have developing this two phase. Phase 1 getting data from cloudsql. I have successfully completed this and unit & integration test cases are working fine. In second step i have included google pubsub dependency.

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
        </dependency>

when added this I am getting following error

Caused by: java.lang.IllegalArgumentException: A database name must be provided.

As i understand after debugging once include the above dependency the code / testing code doesnt refer application.yml file

Note: In application YML file i use spring datasource uRL to connect to Cloud SQL database (which has db name, cloud sql socket factory, cloud instance and username / password) I dont use GCP specific properties for database. For refering google project id use google:cloud:gcp: project-id:


Solution

  • I have solved the problem by removing spring-cloud-gcp-starter-pubsub dependency and added the google pubsub dependency.

              <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>google-cloud-pubsub</artifactId>
            </dependency> 
    

    However still could not find out the root cause of error