This is often the result of over-eager type matching - consider using 'getBeanNamesOfType'

西夏一品堂 发布于 2015/01/28 16:48
阅读 2K+
收藏 0
Exception in thread "main" org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'createDataSource': Bean with name 'createDataSource' has been injected into other beans [dataSourceInitializer] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)

at com.hqit.jd.dbpom.Main.main(Main.java:36)




代码如下:

@Configuration
@EnableAutoConfiguration
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableJpaRepositories()
@ComponentScan()
@EnableAsync
public class Main 
{
    @Autowired
    private Constant constant;
	
    public static void main(String[] args)
    {
        SpringApplication.run(Main.class, args);
    }
    
    @Bean
    public DataSource createDataSource()
    {
    	BoneCPDataSource dataSource = new BoneCPDataSource();
        dataSource.setDriverClass(constant.driverClass);
        dataSource.setJdbcUrl(constant.jdbcUrl);
        dataSource.setUsername(constant.jdbcUsername);
        dataSource.setPassword(constant.jdbcPassword);
        dataSource.setIdleConnectionTestPeriodInMinutes(constant.idleConnectionTestPeriodInMinutes);
        dataSource.setIdleMaxAgeInMinutes(constant.idleMaxAgeInMinutes);
        dataSource.setMaxConnectionsPerPartition(constant.maxConnectionsPerPartition);
        dataSource.setMinConnectionsPerPartition(constant.minConnectionsPerPartition);
        dataSource.setPartitionCount(constant.partitionCount);
        dataSource.setAcquireIncrement(constant.acquireIncrement);
        dataSource.setStatementsCacheSize(constant.statementsCacheSize);
        return dataSource;
    }

	public Constant getConstant() {
		return constant;
	}

	public void setConstant(Constant constant) {
		this.constant = constant;
	}
}



加载中
返回顶部
顶部