Error while compiling SPRING BOOT application

Asked

Viewed 86 times

0

I am trying to compile a java application and is giving this error:

 restartedMain] j.LocalContainerEntityManagerFactoryBean : 
  Failed to initialize JPA EntityManagerFactory: 
   Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.cartorios</groupId>
    <artifactId>apirest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>apirest</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.23.1-GA</version>
</dependency>
        
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

My Aplication:

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
useTimezone=true&serverTimezone=UTC
spring.datasource.username=postgres
spring.datasource.username=
spring.jpa.hibernate.ddl-auto=update
  • 2

    Post the full stacktrace

1 answer

1

Good morning, I believe you will need to create in the properties file the path of the driver of the database you will use, I saw that you declared Postgres is Mysql, so in the application.properties file you will need to put so. spring.datasource.driver-class-name=org.postgresql.Driver. I hope it helps you. :)

  • It worked :D thank you very much!

  • Not only thank, upvote and select as the correct answer. People dedicate their time here to get recognition of their contribution in the future.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.