#179 - Fixed build for multiple-datasources module after Spring Boot 1.4 upgrade.
We now explicitly disable DevToolsDataSourceAutoConfiguration as it currently expects exactly one DataSource being present. Switched to Spring's @Transactional instead of the javax.transactional one.
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package example.springdata.jpa.multipleds;
|
package example.springdata.jpa.multipleds;
|
||||||
|
|
||||||
|
import example.springdata.jpa.multipleds.customer.Customer.CustomerId;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -23,23 +25,27 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
|
||||||
|
import org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import example.springdata.jpa.multipleds.customer.Customer.CustomerId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core Spring Boot application configuration. Note, that we explicitly deactivate some auto-configurations explicitly.
|
* Core Spring Boot application configuration. Note, that we explicitly deactivate some auto-configurations explicitly.
|
||||||
* They mostly will even disable automatically if special bean names are used (e.g. {@code entityManagerFactory}) but I
|
* They mostly will even disable automatically if special bean names are used (e.g. {@code entityManagerFactory}) but I
|
||||||
* wanted to keep the two configurations symmetric. The configuration classes being located in separate packages serves
|
* wanted to keep the two configurations symmetric. The configuration classes being located in separate packages serves
|
||||||
* the purpose of scoping the Spring Data repository scanning to those packages so that the infrastructure setup is
|
* the purpose of scoping the Spring Data repository scanning to those packages so that the infrastructure setup is
|
||||||
* attached to the corresponding repository instances.
|
* attached to the corresponding repository instances.
|
||||||
|
* <p>
|
||||||
|
* {@link DevToolsDataSourceAutoConfiguration} is explicitly excluded until
|
||||||
|
* {@link https://github.com/spring-projects/spring-boot/issues/5540} is fixed.
|
||||||
|
* {@link https://github.com/spring-projects/spring-boot/issues/5541} has been filed to improve the need for manual
|
||||||
|
* exclusions in general.
|
||||||
*
|
*
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
* @see example.springdata.jpa.multipleds.customer.CustomerConfig
|
* @see example.springdata.jpa.multipleds.customer.CustomerConfig
|
||||||
* @see example.springdata.jpa.multipleds.order.OrderConfig
|
* @see example.springdata.jpa.multipleds.order.OrderConfig
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
|
||||||
DataSourceTransactionManagerAutoConfiguration.class })
|
DataSourceTransactionManagerAutoConfiguration.class, DevToolsDataSourceAutoConfiguration.class })
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright 2015-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,10 +18,11 @@ package example.springdata.jpa.multipleds.customer;
|
|||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import example.springdata.jpa.multipleds.Application;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -29,9 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.transaction.TransactionConfiguration;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import example.springdata.jpa.multipleds.Application;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for {@link CustomerRepository}.
|
* Integration test for {@link CustomerRepository}.
|
||||||
@@ -40,8 +39,7 @@ import example.springdata.jpa.multipleds.Application;
|
|||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringApplicationConfiguration(classes = Application.class)
|
@SpringApplicationConfiguration(classes = Application.class)
|
||||||
@Transactional
|
@Transactional(transactionManager = "customerTransactionManager")
|
||||||
@TransactionConfiguration(transactionManager = "customerTransactionManager")
|
|
||||||
public class CustomerRepositoryTests {
|
public class CustomerRepositoryTests {
|
||||||
|
|
||||||
@Autowired CustomerRepository repository;
|
@Autowired CustomerRepository repository;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015 the original author or authors.
|
* Copyright 2015-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,17 +18,15 @@ package example.springdata.jpa.multipleds.order;
|
|||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import example.springdata.jpa.multipleds.Application;
|
||||||
|
import example.springdata.jpa.multipleds.customer.CustomerRepository;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.transaction.TransactionConfiguration;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import example.springdata.jpa.multipleds.Application;
|
|
||||||
import example.springdata.jpa.multipleds.customer.CustomerRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration test for {@link CustomerRepository}.
|
* Integration test for {@link CustomerRepository}.
|
||||||
@@ -37,8 +35,7 @@ import example.springdata.jpa.multipleds.customer.CustomerRepository;
|
|||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringApplicationConfiguration(classes = Application.class)
|
@SpringApplicationConfiguration(classes = Application.class)
|
||||||
@Transactional
|
@Transactional(transactionManager = "orderTransactionManager")
|
||||||
@TransactionConfiguration(transactionManager = "orderTransactionManager")
|
|
||||||
public class OrderRepositoryTests {
|
public class OrderRepositoryTests {
|
||||||
|
|
||||||
@Autowired OrderRepository orders;
|
@Autowired OrderRepository orders;
|
||||||
|
|||||||
Reference in New Issue
Block a user