当前位置: 首页>>代码示例>>Java>>正文


Java HibernateJpaAutoConfiguration类代码示例

本文整理汇总了Java中org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration的典型用法代码示例。如果您正苦于以下问题:Java HibernateJpaAutoConfiguration类的具体用法?Java HibernateJpaAutoConfiguration怎么用?Java HibernateJpaAutoConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HibernateJpaAutoConfiguration类属于org.springframework.boot.autoconfigure.orm.jpa包,在下文中一共展示了HibernateJpaAutoConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testJpaCoexistsHappily

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testJpaCoexistsHappily() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.initialize:false");
	this.context.register(EntityConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
			SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
	// This can fail if security @Conditionals force early instantiation of the
	// HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
	this.context.refresh();
	assertThat(this.context.getBean(JpaTransactionManager.class)).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:SecurityAutoConfigurationTests.java

示例2: testUsingJpa

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testUsingJpa() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	// The order is very important here: DataSource -> Hibernate -> Batch
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	PlatformTransactionManager transactionManager = this.context
			.getBean(PlatformTransactionManager.class);
	// It's a lazy proxy, but it does render its target if you ask for toString():
	assertThat(transactionManager.toString().contains("JpaTransactionManager"))
			.isTrue();
	assertThat(this.context.getBean(EntityManagerFactory.class)).isNotNull();
	// Ensure the JobRepository can be used (no problem with isolation level)
	assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("job",
			new JobParameters())).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:BatchAutoConfigurationTests.java

示例3: testRenamePrefix

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testRenamePrefix() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.name:batchtest",
			"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
			"spring.batch.tablePrefix:PREFIX_");
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
	assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
			.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
	JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
	assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
	JobRepository jobRepository = this.context.getBean(JobRepository.class);
	assertThat(jobRepository.getLastJobExecution("test", new JobParameters()))
			.isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:BatchAutoConfigurationTests.java

示例4: processEngineWithJpaEntityManager

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void processEngineWithJpaEntityManager() throws Exception {
    AnnotationConfigApplicationContext context = this.context(DataSourceAutoConfiguration.class,
            HibernateJpaAutoConfiguration.class, JpaProcessEngineAutoConfiguration.JpaConfiguration.class);
    Assert.assertNotNull("entityManagerFactory should not be null", context.getBean(EntityManagerFactory.class));
    Assert.assertNotNull("the processEngine should not be null!", context.getBean(ProcessEngine.class));
    SpringProcessEngineConfiguration configuration = context.getBean(SpringProcessEngineConfiguration.class);
    Assert.assertNotNull("the " + SpringProcessEngineConfiguration.class.getName() + " should not be null", configuration);
    Assert.assertNotNull(configuration.getJpaEntityManagerFactory());
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:11,代码来源:ProcessEngineAutoConfigurationTest.java

示例5: testDefaultRepositoryConfiguration

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			SpringDataWebAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(CityRepository.class)).isNotNull();
	assertThat(this.context.getBean(PageableHandlerMethodArgumentResolver.class))
			.isNotNull();
	assertThat(this.context.getBean(FormattingConversionService.class)
			.canConvert(Long.class, City.class)).isTrue();
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:18,代码来源:JpaWebAutoConfigurationTests.java

示例6: testJpaCoexistsHappily

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testJpaCoexistsHappily() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.url:jdbc:hsqldb:mem:testsecdb");
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.initialize:false");
	this.context.register(EntityConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
			SecurityAutoConfiguration.class, ServerPropertiesAutoConfiguration.class);
	// This can fail if security @Conditionals force early instantiation of the
	// HibernateJpaAutoConfiguration (e.g. the EntityManagerFactory is not found)
	this.context.refresh();
	assertNotNull(this.context.getBean(JpaTransactionManager.class));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:SecurityAutoConfigurationTests.java

示例7: testDefaultRepositoryConfiguration

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testDefaultRepositoryConfiguration() throws Exception {
	this.context = new AnnotationConfigWebApplicationContext();
	this.context.setServletContext(new MockServletContext());
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			SpringDataWebAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(CityRepository.class));
	assertNotNull(this.context.getBean(PageableHandlerMethodArgumentResolver.class));
	assertTrue(this.context.getBean(FormattingConversionService.class)
			.canConvert(Long.class, City.class));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:JpaWebAutoConfigurationTests.java

示例8: testUsingJpa

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testUsingJpa() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	// The order is very important here: DataSource -> Hibernate -> Batch
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	PlatformTransactionManager transactionManager = this.context
			.getBean(PlatformTransactionManager.class);
	// It's a lazy proxy, but it does render its target if you ask for toString():
	assertTrue(transactionManager.toString().contains("JpaTransactionManager"));
	assertNotNull(this.context.getBean(EntityManagerFactory.class));
	// Ensure the JobRepository can be used (no problem with isolation level)
	assertNull(this.context.getBean(JobRepository.class).getLastJobExecution("job",
			new JobParameters()));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:19,代码来源:BatchAutoConfigurationTests.java

示例9: testRenamePrefix

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test
public void testRenamePrefix() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.name:batchtest",
			"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
			"spring.batch.tablePrefix:PREFIX_");
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertNotNull(this.context.getBean(JobLauncher.class));
	assertEquals(0, new JdbcTemplate(this.context.getBean(DataSource.class))
			.queryForList("select * from PREFIX_JOB_EXECUTION").size());
	JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
	assertEquals(0, jobExplorer.findRunningJobExecutions("test").size());
	JobRepository jobRepository = this.context.getBean(JobRepository.class);
	assertNull(jobRepository.getLastJobExecution("test", new JobParameters()));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:21,代码来源:BatchAutoConfigurationTests.java

示例10: selectImports

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
	List<String> names = new ArrayList<String>();
	for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class,
			MongoDataAutoConfiguration.class,
			MongoRepositoriesAutoConfiguration.class }) {
		names.add(type.getName());
	}
	return names.toArray(new String[0]);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:MixedMongoRepositoriesAutoConfigurationTests.java

示例11: selectImports

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
	List<String> names = new ArrayList<String>();
	for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			Neo4jDataAutoConfiguration.class,
			Neo4jRepositoriesAutoConfiguration.class }) {
		names.add(type.getName());
	}
	return names.toArray(new String[names.size()]);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:MixedNeo4jRepositoriesAutoConfigurationTests.java

示例12: prepareApplicationContext

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
private void prepareApplicationContext(Class<?>... configurationClasses) {
	this.context = new AnnotationConfigApplicationContext();
	this.context.register(configurationClasses);
	this.context.register(EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class,
			JpaRepositoriesAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:JpaRepositoriesAutoConfigurationTests.java

示例13: persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void persistOfNullThrowsIllegalArgumentExceptionWithoutExceptionTranslation() {
	this.context = new AnnotationConfigApplicationContext(
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, TestConfiguration.class);
	this.context.getBean(TestRepository.class).doSomething();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:PersistenceExceptionTranslationAutoConfigurationTests.java

示例14: persistOfNullThrowsInvalidDataAccessApiUsageExceptionWithExceptionTranslation

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
@Test(expected = InvalidDataAccessApiUsageException.class)
public void persistOfNullThrowsInvalidDataAccessApiUsageExceptionWithExceptionTranslation() {
	this.context = new AnnotationConfigApplicationContext(
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, TestConfiguration.class,
			PersistenceExceptionTranslationAutoConfiguration.class);
	this.context.getBean(TestRepository.class).doSomething();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:PersistenceExceptionTranslationAutoConfigurationTests.java

示例15: load

import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; //导入依赖的package包/类
public void load(Class<?> config) {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
	if (config != null) {
		ctx.register(config);
	}
	ctx.register(EmbeddedDataSourceConfiguration.class,
			DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class);
	ctx.register(HazelcastJpaDependencyAutoConfiguration.class);
	ctx.refresh();
	this.context = ctx;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:HazelcastJpaDependencyAutoConfigurationTests.java


注:本文中的org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。