本文整理汇总了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());
}
示例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();
}
示例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));
}
示例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));
}
示例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()));
}
示例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()));
}
示例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