Merge pull request #5836 from rozagerardo/geroza/BAEL-10843_subtask-part-1_BAEL-10354_migrateparent-boot-to-spring-boot-2.1_part-1
BAEL-10843 | Upgrade set of modules to use boot 2.1 - part 1
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package com.baeldung.config;
|
||||
|
||||
import com.baeldung.services.IBarService;
|
||||
import com.baeldung.services.impl.BarSpringDataJpaService;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.baeldung.dao.repositories.impl.ExtendedRepositoryImpl;
|
||||
import com.baeldung.services.IFooService;
|
||||
import com.baeldung.services.impl.FooService;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
@@ -20,13 +21,15 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
import com.baeldung.dao.repositories.impl.ExtendedRepositoryImpl;
|
||||
import com.baeldung.services.IBarService;
|
||||
import com.baeldung.services.impl.BarSpringDataJpaService;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan({"com.baeldung.dao", "com.baeldung.services"})
|
||||
@ComponentScan({ "com.baeldung.dao", "com.baeldung.services" })
|
||||
@EnableTransactionManagement
|
||||
@EnableJpaRepositories(basePackages = {"com.baeldung.dao"}, repositoryBaseClass = ExtendedRepositoryImpl.class)
|
||||
@EnableJpaRepositories(basePackages = { "com.baeldung.dao" }, repositoryBaseClass = ExtendedRepositoryImpl.class)
|
||||
@EnableJpaAuditing
|
||||
@PropertySource("classpath:persistence.properties")
|
||||
public class PersistenceConfiguration {
|
||||
@@ -79,11 +82,6 @@ public class PersistenceConfiguration {
|
||||
return new BarSpringDataJpaService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IFooService fooService() {
|
||||
return new FooService();
|
||||
}
|
||||
|
||||
private final Properties hibernateProperties() {
|
||||
final Properties hibernateProperties = new Properties();
|
||||
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
|
||||
@@ -94,7 +92,8 @@ public class PersistenceConfiguration {
|
||||
// hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
|
||||
|
||||
// Envers properties
|
||||
hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix"));
|
||||
hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix",
|
||||
env.getProperty("envers.audit_table_suffix"));
|
||||
|
||||
return hibernateProperties;
|
||||
}
|
||||
|
||||
@@ -12,4 +12,6 @@ hibernate.cache.use_second_level_cache=true
|
||||
hibernate.cache.use_query_cache=true
|
||||
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory
|
||||
|
||||
spring.datasource.data=import_entities.sql
|
||||
spring.datasource.data=import_entities.sql
|
||||
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
@@ -2,17 +2,12 @@ package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.Application;
|
||||
import com.baeldung.config.PersistenceConfiguration;
|
||||
import com.baeldung.config.PersistenceProductConfiguration;
|
||||
import com.baeldung.config.PersistenceUserConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest(excludeAutoConfiguration = {PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class})
|
||||
@SpringBootTest(classes = Application.class)
|
||||
public class SpringContextIntegrationTest {
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.baeldung.Application;
|
||||
import com.baeldung.config.PersistenceConfiguration;
|
||||
import com.baeldung.config.PersistenceProductConfiguration;
|
||||
import com.baeldung.config.PersistenceUserConfiguration;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@DataJpaTest(excludeAutoConfiguration = {
|
||||
PersistenceConfiguration.class,
|
||||
PersistenceUserConfiguration.class,
|
||||
PersistenceProductConfiguration.class })
|
||||
@ContextConfiguration(classes = Application.class)
|
||||
public class SpringJpaContextIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user