Java 基于spring xml的配置自动连线问题

Java 基于spring xml的配置自动连线问题,java,spring,Java,Spring,我正在运行一个带有xml配置的spring应用程序。我在application-configuration.xml中定义了两个bean,如下所示 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="myDataSource"></property> </bean&

我正在运行一个带有xml配置的spring应用程序。我在application-configuration.xml中定义了两个bean,如下所示

   <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="myDataSource"></property>
   </bean>

   <bean id="myDataSource"
       class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.postgresql.Driver" />
        <property name="url" value="${db.url}" />
        <property name="username" value="${db.username}" />
        <property name="password" value="${db.password}" />
   </bean>
但是jdbcTemplate字段始终为空。 应用程序从另一个类开始

public static void main(String[] args) throws InterruptedException {

   ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("application-configuration.xml");
}
我试着加上

<context:annotation-config/>

到应用程序配置。 我想知道此时是否可以进行基于注释的自动布线,如果可以,我缺少什么?


   <bean id="sQLDbService" class="path.to.your.package.SQLDbService">
        <property name="jdbcTemplate" ref="jdbcTemplate"></property>
   </bean>

SQLDbService是由spring管理的吗?
SQLDbService
也是bean还是独立类?您的xml中有这个类的bean定义吗?您好,它是一个独立的类,没有在xml中定义。那么spring@Autowire如何定义它呢。在xml中为此编写一个bean声明除了xml之外,我还需要更改我提供的代码中的任何内容吗?
   <bean id="sQLDbService" class="path.to.your.package.SQLDbService">
        <property name="jdbcTemplate" ref="jdbcTemplate"></property>
   </bean>