XML中使用@Configuration类

@Configuration
public class ConfigApp{

    @Bean
    public Student student(){
        return new Student();
    }
}
<bean class="com.jianglei.config.ConfigApp"/>
@Autowire
private Student student;

@Configraution类中使用XML

//spring/spring-bean.xml
<bean name="student" class="com.jianglei.bean.Student"/>
@Configuration
@ImportResource("classpath:spring/spring-bean.xml")
public class AppConfig{
}
@Autowire
private Student student;

results matching ""

    No results matching ""