猿问

Spring Boot - 无法确定数据库类型为NONE的嵌入式数据库驱动程序类

我相信我有正确的组合datanucleus-appengine和datanucleus罐子:

2.1:需要DataNucleus 3.1.x(core,api-jdo,api-jpa,enhancer)。需要SDK 1.6.4+请注意,DataNucleus项目不再支持此版本的Datanucleus

JPA App配置:

@Configuration

@EnableJpaRepositories("demo.core.entity")

@EnableTransactionManagement

class JpaApplicationConfig {

    private static final Logger logger = Logger

            .getLogger(JpaApplicationConfig.class.getName());

    @Bean

    public AbstractEntityManagerFactoryBean entityManagerFactory() {

        logger.info("Loading Entity Manager...");

        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();

        factory.setPersistenceUnitName("transactions-optional");

        return factory;

    }

    @Bean

    public PlatformTransactionManager transactionManager() {

        logger.info("Loading Transaction Manager...");

        JpaTransactionManager txManager = new JpaTransactionManager();

        txManager.setEntityManagerFactory(entityManagerFactory().getObject());

        return txManager;

    }

    @Bean

    public PersistenceExceptionTranslator persistenceExceptionTranslator() {

        return new OpenJpaDialect();

    }

}

Application.java


@Configuration

@ComponentScan

@EnableAutoConfiguration

@RestController

public class Application {


    private static final EntityManagerFactory INSTANCE =

            Persistence.createEntityManagerFactory("transactions-optional");


    public static void main(String[] args) {

        SpringApplication.run(Application.class, args);

    }


    @RequestMapping("/")

    public String home() {

        return "Hello World";

    }


}


湖上湖
浏览 866回答 3
3回答

繁华开满天机

如果您想使用Spring Boot的嵌入式H2数据库,请将以下依赖项添加到您的pom文件中。&nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.h2database</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>h2</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.3.156</version>&nbsp; &nbsp; </dependency>但正如评论中所提到的,嵌入式H2数据库将数据保存在内存中,并且不会永久存储它。
随时随地看视频慕课网APP
我要回答