-
Notifications
You must be signed in to change notification settings - Fork 0
Spring Config Setting
Francis Kim edited this page Apr 19, 2016
·
1 revision
[1] Add @PropertySource Annotation at RootApplicationConfig.class
@Configuration
@PropertySource(value = "classpath:properties/default.properties")
public class RootApplicationConfig {
}[2] Add default.properties file at resources directory
[3] If you user @Value Annotation. Add below code in RootApplicationConfig.class
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}[1] Add PlatformTransactionManager Implement class. So I add DataSourceTransactionManager class bean create.
@Bean
public DataSourceTransactionManager dataSourceTransactionManager() {
return new DataSourceTransactionManager(dataSource);
}[2] Add @EnableTransactionManagement Annotation at java config class. ( If you use xml, you add 'tx:anntoation-driven') [Link] Docs
@Configuration
@EnableTransactionManagement()
public class JdbcTemplateConfig {
...
}[3] Add @Transactional Annotation. Now I implement only repository so I add this repoistory Class.
@Repository
public class BoardRepositoryImpl implements BoardRepository {
...
@Override
@Transactional(readOnly = true, propagation = Propagation.REQUIRED, isolation = Isolation.SERIALIZABLE)
public Board insert(Board board) {
...
}
}[Link] Spring Transactional(kor)
Propagation [Link] Docs
- REQUIRED
- REQUIRES_NEW
- SUPPORTS
- NOT_SUPPORTED
- NESTED
- NEVER
- MANDATORY
Isolation [Link] Docs
- READ_COMMITED
- READ_UNCOMMITED
- REPEATABLE_READ
- SERIALIZABLE