org.zodiac.autoconfigure.seata.SeataConfigAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.seata;
import javax.sql.DataSource;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.*;
@SpringBootConfiguration
@ConditionalOnProperty(name = org.zodiac.seata.constants.SeataSystemPropertiesConstants.SEATA_ENABLED, havingValue = "true")
@ConditionalOnClass(value = {org.zodiac.seata.config.SeataConfigInfo.class, io.seata.spring.boot.autoconfigure.SeataAutoConfiguration.class, io.seata.core.context.ContextCore.class})
public class SeataConfigAutoConfiguration {
public SeataConfigAutoConfiguration() {
super();
}
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = org.zodiac.seata.constants.SeataSystemPropertiesConstants.SEATA_PREFIX)
protected SeataConfigProperties seataConfigProperties() {
return new SeataConfigProperties();
}
@Bean
@Primary
@ConditionalOnSingleCandidate(value = DataSource.class)
@ConditionalOnProperty(name = org.zodiac.seata.constants.SeataSystemPropertiesConstants.SEATA_AUTO_PROXY, havingValue = "true")
protected io.seata.rm.datasource.DataSourceProxy dataSourceProxy(DataSource dataSource) {
return new io.seata.rm.datasource.DataSourceProxy(dataSource);
}
}