Merge branch '1.1.x'
This commit is contained in:
commit
01444a03ab
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 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.
|
||||||
|
|
@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoCon
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
|
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
|
||||||
import org.springframework.data.web.config.EnableSpringDataWebSupport;
|
import org.springframework.data.web.config.EnableSpringDataWebSupport;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's web support.
|
* {@link EnableAutoConfiguration Auto-configuration} for Spring Data's web support.
|
||||||
|
|
@ -38,7 +39,8 @@ import org.springframework.data.web.config.EnableSpringDataWebSupport;
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableSpringDataWebSupport
|
@EnableSpringDataWebSupport
|
||||||
@ConditionalOnWebApplication
|
@ConditionalOnWebApplication
|
||||||
@ConditionalOnClass(PageableHandlerMethodArgumentResolver.class)
|
@ConditionalOnClass({ PageableHandlerMethodArgumentResolver.class,
|
||||||
|
WebMvcConfigurerAdapter.class })
|
||||||
@ConditionalOnMissingBean(PageableHandlerMethodArgumentResolver.class)
|
@ConditionalOnMissingBean(PageableHandlerMethodArgumentResolver.class)
|
||||||
@AutoConfigureAfter(RepositoryRestMvcAutoConfiguration.class)
|
@AutoConfigureAfter(RepositoryRestMvcAutoConfiguration.class)
|
||||||
public class SpringDataWebAutoConfiguration {
|
public class SpringDataWebAutoConfiguration {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 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.
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
|
|
@ -158,19 +159,27 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnWebApplication
|
@ConditionalOnWebApplication
|
||||||
|
@ConditionalOnClass(WebMvcConfigurerAdapter.class)
|
||||||
@ConditionalOnMissingBean({ OpenEntityManagerInViewInterceptor.class,
|
@ConditionalOnMissingBean({ OpenEntityManagerInViewInterceptor.class,
|
||||||
OpenEntityManagerInViewFilter.class })
|
OpenEntityManagerInViewFilter.class })
|
||||||
@ConditionalOnProperty(prefix = "spring.jpa", name = "open-in-view", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(prefix = "spring.jpa", name = "open-in-view", havingValue = "true", matchIfMissing = true)
|
||||||
protected static class JpaWebConfiguration extends WebMvcConfigurerAdapter {
|
protected static class JpaWebConfiguration {
|
||||||
|
|
||||||
@Override
|
// Defined as a nested config to ensure WebMvcConfigurerAdapter is not read when
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
// not on the classpath
|
||||||
registry.addWebRequestInterceptor(openEntityManagerInViewInterceptor());
|
@Configuration
|
||||||
}
|
protected static class JpaWebMvcConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor() {
|
||||||
|
return new OpenEntityManagerInViewInterceptor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addWebRequestInterceptor(openEntityManagerInViewInterceptor());
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public OpenEntityManagerInViewInterceptor openEntityManagerInViewInterceptor() {
|
|
||||||
return new OpenEntityManagerInViewInterceptor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue