org.hibernate.HibernateException:

我正在尝试运行一个spring-boot应用程序,它通过spring-jpa使用hibernate,但是我收到了错误

我的pom.xml文件是这样的:

<parent>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-parent</artifactId>

    <version>1.1.8.RELEASE</version>

</parent>


<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.security</groupId>

        <artifactId>spring-security-web</artifactId>

       </dependency>

    <dependency>

        <groupId>org.springframework.security</groupId>

        <artifactId>spring-security-config</artifactId>

    </dependency>

    <dependency>

        <groupId>org.springframework.security</groupId>

        <artifactId>spring-security-taglibs</artifactId>

    </dependency>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-data-jpa</artifactId>

    </dependency>

    <dependency>

        <groupId>commons-dbcp</groupId>

        <artifactId>commons-dbcp</artifactId>

    </dependency>

</dependencies>

我的hibernate配置是(方言配置在这个类的最后一个方法中):


@Configuration

@EnableTransactionManagement

@ComponentScan({ "com.spring.app" })

public class HibernateConfig {


   @Bean

   public LocalSessionFactoryBean sessionFactory() {

      LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();


      sessionFactory.setDataSource(restDataSource());

      sessionFactory.setPackagesToScan(new String[] { "com.spring.app.model" });

      sessionFactory.setHibernateProperties(hibernateProperties());


      return sessionFactory;

   }

我在这做错了什么?


临摹微笑
浏览 1061回答 3
3回答

梵蒂冈之花

在数据库服务器启动时启动应用程序(使用Spring Boot)时,我遇到了类似的问题。Hibernate可以确定自动使用的正确方言,但为了做到这一点,它需要与数据库的实时连接。
打开App,查看更多内容
随时随地看视频慕课网APP