pull/50/head
Phillip Webb 11 years ago committed by Phillip Webb
parent 021fe45d83
commit 7e3cb50a22

@ -39,28 +39,25 @@ import org.springframework.util.ClassUtils;
public class EmbeddedDatabaseConfiguration { public class EmbeddedDatabaseConfiguration {
private static final Map<EmbeddedDatabaseType, String> EMBEDDED_DATABASE_DRIVER_CLASSES; private static final Map<EmbeddedDatabaseType, String> EMBEDDED_DATABASE_DRIVER_CLASSES;
private static final Map<EmbeddedDatabaseType, String> EMBEDDED_DATABASE_URLS;
private EmbeddedDatabase database;
static { static {
Map<EmbeddedDatabaseType, String> drivers = new LinkedHashMap<EmbeddedDatabaseType, String>();
drivers.put(EmbeddedDatabaseType.H2, "org.h2.Driver");
drivers.put(EmbeddedDatabaseType.DERBY, "org.apache.derby.jdbc.EmbeddedDriver");
drivers.put(EmbeddedDatabaseType.HSQL, "org.hsqldb.jdbcDriver");
EMBEDDED_DATABASE_DRIVER_CLASSES = drivers;
}
EMBEDDED_DATABASE_DRIVER_CLASSES = new LinkedHashMap<EmbeddedDatabaseType, String>(); private static final Map<EmbeddedDatabaseType, String> EMBEDDED_DATABASE_URLS;
EMBEDDED_DATABASE_DRIVER_CLASSES.put(EmbeddedDatabaseType.H2, "org.h2.Driver"); static {
EMBEDDED_DATABASE_DRIVER_CLASSES.put(EmbeddedDatabaseType.DERBY, Map<EmbeddedDatabaseType, String> urls = new LinkedHashMap<EmbeddedDatabaseType, String>();
"org.apache.derby.jdbc.EmbeddedDriver"); urls.put(EmbeddedDatabaseType.H2, "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1");
EMBEDDED_DATABASE_DRIVER_CLASSES.put(EmbeddedDatabaseType.HSQL, urls.put(EmbeddedDatabaseType.DERBY, "jdbc:derby:memory:testdb;create=true");
"org.hsqldb.jdbcDriver"); urls.put(EmbeddedDatabaseType.HSQL, "jdbc:hsqldb:mem:testdb");
EMBEDDED_DATABASE_URLS = urls;
EMBEDDED_DATABASE_URLS = new LinkedHashMap<EmbeddedDatabaseType, String>();
EMBEDDED_DATABASE_URLS.put(EmbeddedDatabaseType.H2,
"jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1");
EMBEDDED_DATABASE_URLS.put(EmbeddedDatabaseType.DERBY,
"jdbc:derby:memory:testdb;create=true");
EMBEDDED_DATABASE_URLS.put(EmbeddedDatabaseType.HSQL, "jdbc:hsqldb:mem:testdb");
} }
private EmbeddedDatabase database;
@Bean @Bean
public DataSource dataSource() { public DataSource dataSource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder() EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder()

@ -98,6 +98,12 @@ public class WebMvcAutoConfiguration {
} }
} }
@Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
return new HiddenHttpMethodFilter();
}
// Defined as a nested config to ensure WebMvcConfigurerAdapter it not read when not // Defined as a nested config to ensure WebMvcConfigurerAdapter it not read when not
// on the classpath // on the classpath
@EnableWebMvc @EnableWebMvc
@ -111,24 +117,24 @@ public class WebMvcAutoConfiguration {
@Autowired @Autowired
private ResourceLoader resourceLoader; private ResourceLoader resourceLoader;
@Bean
@ConditionalOnBean(View.class) @ConditionalOnBean(View.class)
@ConditionalOnMissingBean(InternalResourceViewResolver.class) @ConditionalOnMissingBean(InternalResourceViewResolver.class)
@Bean
public InternalResourceViewResolver defaultViewResolver() { public InternalResourceViewResolver defaultViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver(); InternalResourceViewResolver resolver = new InternalResourceViewResolver();
return resolver; return resolver;
} }
@ConditionalOnBean(View.class)
@Bean @Bean
@ConditionalOnBean(View.class)
public BeanNameViewResolver beanNameViewResolver() { public BeanNameViewResolver beanNameViewResolver() {
BeanNameViewResolver resolver = new BeanNameViewResolver(); BeanNameViewResolver resolver = new BeanNameViewResolver();
resolver.setOrder(0); resolver.setOrder(0);
return resolver; return resolver;
} }
@ConditionalOnBean(View.class)
@Bean @Bean
@ConditionalOnBean(View.class)
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) { public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver(); ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
resolver.setContentNegotiationManager(beanFactory resolver.setContentNegotiationManager(beanFactory
@ -211,12 +217,7 @@ public class WebMvcAutoConfiguration {
return requestHandler; return requestHandler;
} }
} }
}
@Bean
@ConditionalOnMissingBean(HiddenHttpMethodFilter.class)
public HiddenHttpMethodFilter hiddenHttpMethodFilter() {
return new HiddenHttpMethodFilter();
} }
} }

Loading…
Cancel
Save