org.axonframework.boot.autoconfig.JdbcAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axon-spring-boot-autoconfigure Show documentation
Show all versions of axon-spring-boot-autoconfigure Show documentation
Module providing support for auto-configuration of Axon Framework through Spring Boot.
package org.axonframework.boot.autoconfig;
import org.axonframework.common.jdbc.ConnectionProvider;
import org.axonframework.common.jdbc.PersistenceExceptionResolver;
import org.axonframework.common.jdbc.UnitOfWorkAwareConnectionProviderWrapper;
import org.axonframework.eventsourcing.eventstore.jdbc.JdbcSQLErrorCodesResolver;
import org.axonframework.eventsourcing.eventstore.jpa.SQLErrorCodesResolver;
import org.axonframework.spring.jdbc.SpringDataSourceConnectionProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.sql.SQLException;
@ConditionalOnBean(DataSource.class)
@Configuration
public class JdbcAutoConfiguration {
@ConditionalOnMissingBean
@ConditionalOnBean(DataSource.class)
@Bean
public PersistenceExceptionResolver dataSourcePersistenceExceptionResolver(DataSource dataSource) throws SQLException {
return new SQLErrorCodesResolver(dataSource);
}
@ConditionalOnMissingBean({DataSource.class, PersistenceExceptionResolver.class})
@Bean
public PersistenceExceptionResolver jdbcSQLErrorCodesResolver() {
return new JdbcSQLErrorCodesResolver();
}
@ConditionalOnMissingBean
@Bean
public ConnectionProvider connectionProvider(DataSource dataSource) {
return new UnitOfWorkAwareConnectionProviderWrapper(new SpringDataSourceConnectionProvider(dataSource));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy