I do connection to a DB.
error code
@Qualifier ("mainDatasource") - the compiler writes Could not autowire. Qualified bean must be of the 'DataSource' type. less ... (Ctrl + F1) Inspection info: Checks autowiring problems in a bean class.
@Singleton @Interceptors(SpringBeanAutowiringInterceptor.class) @Configuration public class DataSourceSingleton { @Autowired @Qualifier("mainDatasource") private DataSource dataSource; public DataSource getDataSource() { return dataSource; } } class that pulls him
@Repository public class KladrRepository { private static final Logger log = Logger.getLogger(KladrRepository.class); @Autowired private DataSourceSingleton holderData; @Resource private SpAddCoordinate spAddCoordinate; @Resource private CoordinateCache coordinateCache; private SpGetDataForYandexMap getAccountInfo; @PostConstruct public void postConstruct() { getAccountInfo = new SpGetDataForYandexMap(holder.getDataSource()); } public Map<Long, Pair<Double, Double>> getIdCoordinates() throws RepositoryException { return coordinateCache. getIdCoordinates(); } } configuration file
<bean id="kladrRepository" class="ru.liberty.kladr.yandex.db.KladrRepository" init-method="postConstruct"> </bean> <bean id="kladrDataSourceSingleton" class="ru.liberty.kladr.yandex.db.KladrDataSourceSingleton"> </bean> <bean id="dataSourceSingleton" class="ru.liberty.kladr.yandex.db.DataSourceSingleton"> </bean> <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="post.kfins.ru"/> </bean> <!--DataSources--> <bean id="mainDatasource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:jboss/kfins-front/SybaseDB"/> </bean>