SpringBoot beanFactory.getBean(PlatformTransactionManager.class)非常慢

时间:2017-11-22 11:16:41

标签: java spring-boot grpc-java

springboot auto config TransactionManagerSqlFactory,它运行良好,但当我使用@Transactional程序等待发呆时,我会流动代码并查找 beanFactory.getBean(PlatformTransactionManager.class)非常慢。 但是当我添加这个:

@Autowired
private PlatformTransactionManager platformTransactionManager;

它有效。所以有什么问题。我不知道,我现在正在使用带有springboot的grpc,请帮助thx;

@Configuration
@SpringBootApplication
@ComponentScan(value = "cn.com.autohome.autopay.wallet")
@EnableTransactionManagement
@EnableAutoConfiguration
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class AppMain extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(AppMain.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(AppMain.class);
    }
}

@Configuration
@MapperScan(basePackages = "cn.com.autohome.autopay.wallet.core.dal.mapper")
@ImportResource(locations = {"classpath:wallet-dal-bean.xml"})
public class WalletMyBatisConfig {

    @Autowired
    private DataBaseProperties dataBaseProperties;

    @Primary
    @Bean(name = "walletDataSource")
    @ConfigurationProperties("spring.datasource.druid")
    public DataSource masterDataSource() throws SQLException {
        DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
        dataSource.setDriverClassName(dataBaseProperties.getWallet_data_source_driver_class());
        dataSource.setUrl(dataBaseProperties.getWallet_data_source_url());
        dataSource.setUsername(dataBaseProperties.getWallet_data_source_username());
        dataSource.setPassword(dataBaseProperties.getWallet_data_source_password());
        return dataSource;
    }
}

0 个答案:

没有答案