use of org.springframework.context.annotation.Primary in project spring-boot-examples by ityouknow.
the class DataSource1Config method testSqlSessionFactory.
@Bean(name = "test1SqlSessionFactory")
@Primary
public SqlSessionFactory testSqlSessionFactory(@Qualifier("test1DataSource") DataSource dataSource) throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mybatis/mapper/test1/*.xml"));
return bean.getObject();
}
use of org.springframework.context.annotation.Primary in project earth-snow by justlive1.
the class WebConfig method jsonConverter.
@Primary
@Bean
public MappingJackson2HttpMessageConverter jsonConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper());
converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8, MediaType.TEXT_PLAIN));
return converter;
}
use of org.springframework.context.annotation.Primary in project earth-snow by justlive1.
the class WebConfig method objectMapper.
@Primary
@Bean
ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
// 使用JsonView处理某个具体请求时Pojo转换成Json时显示内容
mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion(Include.NON_NULL);
return mapper;
}
use of org.springframework.context.annotation.Primary in project tutorials-java by Artister.
the class MasterDataSourceConfig method masterSqlSessionFactory.
@Bean(name = "masterSqlSessionFactory")
@Primary
public SqlSessionFactory masterSqlSessionFactory(@Qualifier("masterDataSource") DataSource masterDataSource) throws Exception {
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(masterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MasterDataSourceConfig.MAPPER_LOCATION));
return sessionFactory.getObject();
}
use of org.springframework.context.annotation.Primary in project modesti by jlsalmon.
the class JpaConfig method coreTransactionManager.
@Bean
@Primary
public JpaTransactionManager coreTransactionManager(EntityManagerFactoryBuilder builder) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(coreEntityManagerFactory(builder).getObject());
return transactionManager;
}
Aggregations