admin管理员组

文章数量:1300174

I have a Spring Boot 3 project with a H2 database that I want to run in a Docker container, but it doesn't run.

I'm using those commands:

docker build -t spring-hope .
docker run -p 8080:8080 spring-hope

This is the configuration:

application.yml:

spring:
  application:
    name: hope
  datasource:
    driver-class-name: .h2.Driver
    username: sa
    password:
  jpa:
    database-platform: .hibernate.dialect.H2Dialect
    hibernate:
      ddl-auto: update
  properties:
    jakarta.persistence.jdbc.url: jdbc:h2:mem:testdb
    hibernate.dialect: .hibernate.dialect.H2Dialect
  h2:
    console:
      enabled: true
      path: /h2-console
server:
  error:
    include-message: always
    include-binding-errors: always

And it throws this exception: .txt

This is the repository:

What is going on guys?

I have a Spring Boot 3 project with a H2 database that I want to run in a Docker container, but it doesn't run.

I'm using those commands:

docker build -t spring-hope .
docker run -p 8080:8080 spring-hope

This is the configuration:

application.yml:

spring:
  application:
    name: hope
  datasource:
    driver-class-name: .h2.Driver
    username: sa
    password:
  jpa:
    database-platform: .hibernate.dialect.H2Dialect
    hibernate:
      ddl-auto: update
  properties:
    jakarta.persistence.jdbc.url: jdbc:h2:mem:testdb
    hibernate.dialect: .hibernate.dialect.H2Dialect
  h2:
    console:
      enabled: true
      path: /h2-console
server:
  error:
    include-message: always
    include-binding-errors: always

And it throws this exception: https://github/ocardenasmartinez1984/hope/blob/main/error.txt

This is the repository: https://github/ocardenasmartinez1984/hope

What is going on guys?

Share Improve this question edited Feb 11 at 15:20 Octavio Cárdenas asked Feb 11 at 14:09 Octavio CárdenasOctavio Cárdenas 978 bronze badges 6
  • Is the actual error message the GitHub URL, or is there some actual text? Can you edit the question to include the error directly in the text? (The question should still make sense even after you git rm the old error message.) – David Maze Commented Feb 11 at 14:12
  • Remove the persistence.xml, remove the jakarta.persistence.jdbc.url property, as well as the driver-class-name. Add a url property to spring.datasource (or ditch it all together. – M. Deinum Commented Feb 11 at 14:28
  • @DavidMaze that url is actual error. – Octavio Cárdenas Commented Feb 11 at 15:05
  • @M.Deinum, I've deleted the persistence.xml file however I have the same error – Octavio Cárdenas Commented Feb 11 at 15:07
  • Did you stop reading after remove persistence.xml? Remove more from your confguration. When I do that it works for me. – M. Deinum Commented Feb 11 at 15:19
 |  Show 1 more comment

1 Answer 1

Reset to default 0

I cloned your GitHub-repository and changed your application.yml to a minimum, and app starts without errors. Built with ./gradlew clean bootJar, then ran the Docker-commands.

spring:
  application:
    name: hope

  jpa:
    open-in-view: false
    hibernate:
      ddl-auto: update

  h2:
    console:
      enabled: true

本文标签: Spring Boot 3 doesn39t run in DockerStack Overflow