3

I am running a spring boot application that should connect to a database using hibernate, however I am getting the following exception: Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

My application.properties

server.port=9000
spring.datasource.url=jdbc:mysql://localhost/Users
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root

Here is my pom.xml

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.9.RELEASE</version>
</parent>
<properties>
    <spring.boot.version>1.1.8.RELEASE</spring.boot.version>
    <start.class>com.server.boot.Starter</start.class>
    <spring.core.version>4.0.6.RELEASE</spring.core.version>
    <log4j.version>1.2.17</log4j.version>
    <tomcat.version>8.0.8</tomcat.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.core.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
    </dependency>
</dependencies>

My configuration class:

@Configuration
@ComponentScan({"com.server"})
@EnableAutoConfiguration
public class Starter {
    public static void main(String[] args){
        SpringApplication.run(Starter.class,args);
        System.out.println("started application");
    }   
    @Bean
    public LoginController loginController(){
        return new LoginController();
    }   
}

And my controller:

@Service
@Transactional
@RestController
@RequestMapping("/user")
public class LoginController {
    
    @PersistenceContext
    private EntityManager entityManager;
    
    @RequestMapping(value="/login",method=RequestMethod.POST)
    public String login(@RequestParam(value="username",required=true) String username, 
                        @RequestParam(value="password",required=true) String password){
        return "Tried to login as "+username + " where em is "+entityManager;
    }
}

What is the cause of this?


Upon further research

I believe the answer to this question org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set solved it

pixel
  • 9,653
  • 16
  • 82
  • 149
mangusbrother
  • 3,988
  • 11
  • 51
  • 103
  • 1
    For MySQL just add in the application.proeprties: spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect – Xelian Jul 24 '16 at 11:51
  • @pixel The OP themself confirmed that that question solved their problem. Please don't waste time of reviewers by pushing things unnecessarily into the reopen review queue. – Mark Rotteveel May 19 '22 at 10:36
  • @MarkRotteveel I dont, provide option to remove request to reopen and problem solved as I explained it was by mistake. But it looks like you are not aware of that, so obviously missing functionality to revert accidentaly requested reopen. Maybe add that to save some time, just a suggestion – pixel May 19 '22 at 14:24
  • @pixel You seem to think I work for Stack Overflow, I do not. If you want to suggest improvements, you can do so on [meta]. – Mark Rotteveel May 19 '22 at 14:26

0 Answers0