Created
April 8, 2011 12:16
-
-
Save cbeams/909722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@TxAnnotationDriven | |
@ImportResource("classpath:/com/company/app/db-config.xml") | |
public class AppConfig { | |
@Inject Environment env; | |
@Inject DataSource dataSource; // from XML -> won't work; @Feature forces autowiring before BFPP! | |
// ---- configure data infrastructure ---- | |
public @Bean SessionFactory sessionFactory() { ... } | |
public @Bean PersistenceExceptionTranslationPostProcessor exceptionTranslationPostProcessor() { ... } | |
public @Bean PersistenceExceptionTranslator exceptionTranslator() { ... } | |
public @Bean PlatformTransactionManager txManager() { ... } | |
// ---- configure service and repository layers ---- | |
// ... | |
// ---- configure MVC controllers and infrastructure ---- | |
public @Bean FormattingConversionService conversionService() { ... } | |
public @Bean Validator validator() { ... } | |
public @Bean MessageCodesResolver messageCodesResolver() { ... } | |
@Feature | |
public MvcAnnotationDriven annotationDriven() { | |
return new MvcAnnotationDriven() | |
.conversionService(conversionService()) | |
.messageCodesResolver(messageCodesResolver()) | |
.validator(validator()) | |
.messageConverters(new StringHttpMessageConverter()) | |
.argumentResolvers(new TestWebArgumentResolver()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans> | |
<bean class="org.sfwk..PropertyPlaceholderConfigurer"> | |
<property name="location" value="classpath:/com/company/app/db.properties"/> | |
</bean> | |
<bean id="dataSource" class="..."> | |
<property name="driverClass" value="${db.driverClass}"/> | |
<property name="url" value="${db.url}"/> | |
<property name="username" value="${db.username}"/> | |
<property name="password" value="${db.password}"/> | |
</bean> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment