java - addPropertyReference cannot be applied to abstractBeanDefinition -


I am trying to create beans on runtime based on entries in a config file.

I have a class that implements BeanDefinitionRegistryPostProcessor , and I have the following code in postProcessBeanDefinitionRegistry

  (DataSourceConfig dsc: configuration.getDatabase ()) {AbstractBeanDefinition jdbcTemplateDefinition = BeanDefinitionBuilder.rootBeanDefinition ("com.me.threads.RemoteDataCollector") .addPropertyReference ("remoteDBDoa", BeanDefinitionBuilder.rootBeanDefinition ("com.me.db.RemoteDBDoa" ) .addPropertyValue ("jdbcTemplateRemote", BeanDefinitionBuilder.rootBeanDefinition ("Organization .springframework.jdbc.core.JdbcTemplate") .addPropertyValue ("Data Source", Bendiffin Itionbuilder.genericBeanDefinition (DriverManagerDataSource.class) .addPropertyValue ("driverClassName", dsc. GetDriverClassName ()) .addPropertyValue ("url", dsc.getUrl ()) .a DdPropertyValue ("user name", dsc.getUsername ()) .addPropertyValue ("password", dsc.getPassword ()) .getBeanDefinition ()) .getBeanDefinition ()) .getBeanDefinition () string name = BeanDefinitionReaderUtils.registerWithGeneratedName (jdbcTemplateDefinition, Registry); JdbcTemplateBeanNames.put (dsc.getName (), name); }  

There is an issue within this code that I want to find CNT. Is this the perfect way to accomplish what I want or is there a better way?

I re-code for the following

  (DataSourceConfig DSC: configuration.getDatabase ()) {BinDefinitionBuilder DETROSER DEF = BinDefinitionBuilderGenericBean Definition (DriverManagerDataSource.class); DatasourceDiff.edprobertewell ("driverClassName", dsc.getDriverClassName ()); DataSourceDiff.edproperty ("url", dsc.getUrl ()); DatasourceDef.addPropertyValue ("user name", dsc.getUsername ()); DatasourceDiff.edproperty ("password", dsc.getPassword ()); BinDefinitionBuilder jdbcTemplateDef = BinDefinitionBuilder. GenericBeanDefinition (org.springframework.jdbc.core.JdbcTemplate.class); JdbcTemplateDef.addPropertyValue ("Datasource", DatasetDef.Getbin Definition ()); BinDefinitionBuilder Dao Def = BinDefinitionBuilder GenericBeanDefinition (com.me.db.RemoteDBDoa.class); DaoDef.addPropertyValue ("jdbcTemplateRemote", jdbcTemplateDef.getBeanDefinition ()); BinDefinitionBilder Collector DEF = BendiditionBuilder. Rotbin's Definition (Comm. My Thread.RomodedActalator.class); Collector Def.Ad Property Value ("Remote DBDOA", DOAADF.FABANDEFINATION ()); String Name = BinDiffinition Reader Utilities Registry with GeneratedName (Collector Definition .getBeanDefinition (), Registry); JdbcTemplateBeanNames.put (dsc.getName (), name); }  

which is clear imho, I will probably step into the construction of the DAO of JdbcTemplate which will allow you to inject the DataSource in your DAO Allowing you to mess with the definition of extra bean.


Comments

Popular posts from this blog

c++ - ERROR: cannot open source file x11\xlib.h -

c - What are pthread cancelation points used for? -

c# - Show a huge number of data in DevExpress GridView -