當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。