我相信我有正确的组合datanucleus-appengine和datanucleus罐子:2.1:需要DataNucleus 3.1.x(core,api-jdo,api-jpa,enhancer)。需要SDK 1.6.4+请注意,DataNucleus项目不再支持此版本的DatanucleusJPA App配置:@Configuration@EnableJpaRepositories("demo.core.entity")@EnableTransactionManagementclass 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@RestControllerpublic 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"; }}
3 回答
繁华开满天机
TA贡献1816条经验 获得超4个赞
如果您想使用Spring Boot的嵌入式H2数据库,请将以下依赖项添加到您的pom文件中。
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.156</version>
</dependency>
但正如评论中所提到的,嵌入式H2数据库将数据保存在内存中,并且不会永久存储它。
添加回答
举报
0/150
提交
取消