Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

r2dbc with graalvm SPRING_R2DBC_URL not recognised #1936

Closed
altfatterz opened this issue Nov 13, 2024 · 1 comment
Closed

r2dbc with graalvm SPRING_R2DBC_URL not recognised #1936

altfatterz opened this issue Nov 13, 2024 · 1 comment
Labels
for: external-project For an external project and not something we can fix

Comments

@altfatterz
Copy link

Hi,

I would like to build a native image for an app which using R2DBC to access PostgreSQL.
Not sure why but with the following docker compose file the SPRING_R2DBC_URL is not recognised, I receive:

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a ConnectionFactory: 'url' attribute is not specified and no embedded database could be configured.

Reason: Failed to determine a suitable R2DBC Connection URL
services:
  app:
    image: 'docker.io/library/postgresql-r2dbc:0.0.1-SNAPSHOT'
    depends_on:
      db:
        condition: service_healthy
     # Not recognised configuration
#    environment:
#      - 'SPRING_R2DBC_URL=r2dbc:postgresql://db:5432/postgres'
#      - 'SPRING_R2DBC_USERNAME=postgres'
#      - 'SPRING_R2DBC_PASSWORD=secret'
    ports:
      - '8080:8080'
  db:
    image: 'postgres:16'
    ports:
      - '5432:5432'
    environment:
      - 'POSTGRES_DB=postgres'
      - 'POSTGRES_PASSWORD=secret'
      - 'POSTGRES_USER=postgres'
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready" ]
      interval: 2s
      timeout: 2s
      retries: 3

If I bake the configuration into the image then the connection to PostgreSQL works

spring:
  application:
    name: postgresql-r2dbc
  sql.init.mode: always
  # If we bake the configuration into the image then the connection to PostgreSQL works
  r2dbc:
    url: r2dbc:postgresql://db:5432/postgres
    username: postgres
    password: secret

Interestingly with JDBC the external configuration works, for R2DBC do I need any specific configuration ?

I build the image using:

$ mvn clean install
$ mvn -Pnative spring-boot:build-image

I created an example here: https://github.com/altfatterz/learning-spring/tree/master/postgresql-r2dbc

Any feedback appreciated.

Thank you.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 13, 2024
@mp911de
Copy link
Member

mp911de commented Nov 13, 2024

Picking up config properties is Spring Boot functionality. I suggest that you file the same ticket into https://github.com/spring-projects/spring-boot/issues.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
@mp911de mp911de added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants