可执行JAR Bean创建-不起作用

时间:2018-11-26 07:08:31

标签: java maven sqlite spring-boot jdbc

以下代码段/代码在Eclipse中运行,但是当我构建可执行JAR并尝试运行它时,它显示以下错误,

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.UnsupportedOperationException: No add column syntax supported by org.hibernate.dialect.SQLiteDialect
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
        .....
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.UnsupportedOperationException: No add column syntax supported by org.hibernate.dialect.SQLiteDialect
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:402) ~[spring-orm-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) ~[spring-orm-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
        ....
Caused by: java.lang.UnsupportedOperationException: No add column syntax supported by org.hibernate.dialect.SQLiteDialect
        at org.hibernate.dialect.Dialect.getAddColumnString(Dialect.java:2088) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
        at org.hibernate.mapping.Table.sqlAlterStrings(Table.java:472) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]
        at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.migrateTable(AbstractSchemaMigrator.java:299) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]

数据库配置-

public DataSource dataSource() {
        DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
        dataSourceBuilder.driverClassName("org.sqlite.JDBC");
        //dataSourceBuilder.url("jdbc:sqlite:/C:/Projects/project1/db/sampledata.db3"); // working fine, when running through eclipse
        dataSourceBuilder.url("jdbc:sqlite:sampledata.db3"); // working fine when running through eclipse

        return dataSourceBuilder.build();   
}

application.properties

spring.profiles.active=dev
#spring.jpa.properties.hibernate.dialect= com.example.demo.config.SQLiteDialect
spring.jpa.properties.hibernate.connection.url = org.sqlite.JDBC
spring.jpa.database-platform= com.example.demo.config.SQLiteDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

可执行jar-在这种情况下需要提供什么数据库路径?

我已经推荐了其中的几个,试图使用:resource,但是没有用。因此,我们将不胜感激。

0 个答案:

没有答案