Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

708
Visualizações
Spring Boot + PostgreSQL: error al crear un bean con el nombre 'entityManagerFactory' definido en el recurso de ruta de clase

Tengo un problema al conectar Spring Boot con PostgreSQL. Parece que no puedo hacer que funcione. Si falta algo puedo darte más pero por ahora es suficiente información

el error completo:

 Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.2.RELEASE:run (default-cli) on project resorts-restful-project: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

aquí está mi configuración:

aplicaciones.propiedades:

 spring.datasource.url= jdbc:postgresql://localhost:5433/qwerty spring.datasource.username=postgres spring.datasource.password=postgres@qwerty spring.jpa.hibernate.ddl-auto=create-drop

mi modelo:

 package com.fvthree.domain; import javax.persistence.*; import java.io.Serializable; @Entity public class Resort implements Serializable { @Id @GeneratedValue @Column(name="resorts_id") private Long id; @Column(name="name") private String name; @Column(name="location") private String location; @Column(name="contact_id") private Long contactId; public Resort() { } public Resort(Long id, String name, String location, Long contactId) { this.id = id; this.name = name; this.location = location; this.contactId = contactId; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public Long getContactId() { return contactId; } public void setContactId(Long contactId) { this.contactId = contactId; } }
about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Asegúrese de tener todas estas propiedades establecidas:

 spring.datasource.driverClassName=org.postgresql.Driver spring.datasource.url= spring.datasource.username= spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.show-sql=false spring.jpa.hibernate.ddl-auto=create-drop

Y tienes estas anotaciones habilitadas en la clase con main():

 @Configuration @EnableAutoConfiguration @ComponentScan public class Application { public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } }
about 4 years ago · Santiago Trujillo Relatório

0

Ya arreglé el problema.

El archivo application.properties debe estar completo:

 # Configure postgres spring.jpa.database=POSTGRESQL spring.datasource.platform=postgres spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=create-drop spring.database.driverClassName=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://localhost:5432/qweqwe spring.datasource.username=postgres spring.datasource.password=dontcopythis

También agrego @EntityScan y @EnableJpaRepositories al principal:

 package com.fvthree; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication @EntityScan(basePackages = {"com.fvthree.domain" }) @EnableJpaRepositories(basePackages = {"com.fvthree.repository"}) public class ResortsRestfulProjectApplication { public static void main(String[] args) { SpringApplication.run(ResortsRestfulProjectApplication.class, args); } }
about 4 years ago · Santiago Trujillo Relatório

0

(1) En su archivo application.properties , observe que spring.datasource.username=postgres spring.datasource.password=postgres@qwerty tiene 2 líneas, no 1 línea.

(2) Porque este error:

El acceso a DialectResolutionInfo no puede ser nulo cuando 'hibernate.dialect' no está configurado

Te estás perdiendo hibernate.dialect=...

Por ejemplo, si usa PostgreSQL 9.5, será hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect

Referencia: https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/dialect/package-summary.html

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda