The bean obtained through annotations is null

problem description

applicationContext.xmlbean@AutowirednullApplicationContext ctx = new ClassPathXmlApplicationContext("conf/spring/applicationContext.xml");ctx.getBean()

related codes

<bean id="dalClient" class="com.zhl.framework.dal.client.support.DefaultDalClient">
    <property name="resources" value="classpath:sqlmapper/sqlMap_*.xml" />
    <property name="defaultDataSource" ref="dataSource" />
</bean>

this is an encapsulated method to access sql files

<servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:conf/spring/spring-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

this is the web configuration

what result do you expect? What is the error message actually seen?

Mar.29,2021

1. Whether the scan is configured or not, the injection mechanism of spring can go to
2, whether it is hosted by spring, whether it is new or can be injected.
I have written a thread business class before, into which bean cannot be injected. You need to new out
thread to get bean

.
ApplicationContext ac = new FileSystemXmlApplicationContext("classpath:spring.xml");  
ac.getBean("companyService"); 
Menu