Spring The Bean property entered is null

I'm new to the whole idea of ​​injecting beans, so speak slowly. :)

I have a class that introduces a bean, but when accessing the property, the property is null, and I get an exception with a null pointer.

From / project-TRUNK / war-module / src / main / webapp / WEB-INF / spring -config / spring - bean.xml

 <bean id="linkCheck"
  class="com.dogwatch.util.LinkCheck">
  <property name="linkDao" ref="jdbcLinkDao" />
 </bean>

From / project-TRUNK / war-module / src / main / webapp / WEB-INF / spring -config / spring -dao.xml

 <bean id="jdbcLinkDao" class="com.dogwatch.util.jdbcLinkDao">
  <property name="dataSource" ref="dataSource" />
  <property name="linkJdbcDataTypesSupport" ref="linkJdbcDataTypesSupport"/>
 </bean>

DAO bean is known to be good and works in several other classes.

package com.dogwatch.util;
public class LinkCheck {

 private LinkDAO linkDao;


 public LinkDAO getLinkDao() {
  return linkDao;
 }

 public void setLinkDao(LinkDAO linkDao) {
  this. linkDao = linkDao;
 }
}

I have compared it to other classes using the same DAO bean, and I cannot find any differences.

I see how a bean is defined in:

INFO [2010-01-15 01:10: 05,838] [] [XmlBeanDefinitionReader] [XmlBeanDefinitionReader.java:323] - XML bean URL- [: -/SRC//-/WEB-INF/spring -config/spring -dao.xml] INFO [2010-01-15 01:10: 05,858] [] [XmlBeanDefinitionReader] [XmlBeanDefinitionReader.java:323] - XML bean URL- [: -/SRC//-/WEB-INF/spring -config/spring - bean.xml] INFO [2010-01-15 01:10: 06,597] [] [DefaultListableBeanFactory] [DefaultListableBeanFactory.java:414] - org.springframework.beans.factory.support.DefaultListableBeanFactory@3c01d5a0: beans [(snip) jdbcLinkDao, linkCheck () businessLoggingAspect, org.springframework.beans.factory.config.PropertyPlaceholderConfigurer # 1]; root factory

- - bean ?

+3
2

OP, , , ...

- , , , Check bean, ? ? Spring? , new LinkCheck(), Spring, .

Spring beans, beans: new MyClass(), Spring .

+8

, "jdbcLinkDao" - "jdbcLinkDao" , - LinkDAO. ( "jdbcLinkDao" "LinkDAO", , , ... !)

, :

  • DEBUG,

  • , LinkCheck.setLinkDAO(), , ... .

+1

Source: https://habr.com/ru/post/1728577/


All Articles