@Configuration注釈付きクラスを作成します。
@Configuration
public class MyApplicationContext {
}
 
<bean>タグごとに、アノテーションが付けられたメソッドを作成します@Bean。
@Configuration
public class MyApplicationContext {
  @Bean(name = "someBean")
  public SomeClass getSomeClass() {
    return new SomeClassImpl(someInterestingProperty); // We still need to inject someInterestingProperty
  }
  @Bean(name = "anotherBean")
  public AnotherClass getAnotherClass() {
    return new AnotherClassImpl(getSomeClass(), beanFromSomewhereElse); // We still need to inject beanFromSomewhereElse
  }
}
 
インポートbeanFromSomewhereElseするには、その定義をインポートする必要があります。これはXMLで定義でき、次のように使用します@ImportResource。
@ImportResource("another-application-context.xml")
@Configuration
public class MyApplicationContext {
  ...  
}
Beanが別の@Configurationクラスで定義されている場合は、@Importアノテーションを使用できます。
@Import(OtherConfiguration.class)
@Configuration
public class MyApplicationContext {
  ...
}
 
他のXMLまたは@Configurationクラスをインポートした後@Configuration、次のようにクラスにプライベートメンバーを宣言することにより、コンテキストで宣言したBeanを使用できます。
@Autowired
@Qualifier(value = "beanFromSomewhereElse")
private final StrangeBean beanFromSomewhereElse;
または、次のようにbeanFromSomewhereElse使用し@Qualifierて、これに依存するBeanを定義するメソッドのパラメーターとして直接使用します。
@Bean(name = "anotherBean")
public AnotherClass getAnotherClass(@Qualifier (value = "beanFromSomewhereElse") final StrangeBean beanFromSomewhereElse) {
  return new AnotherClassImpl(getSomeClass(), beanFromSomewhereElse);
}
 
プロパティのインポートは、別のXMLまたは@ConfigurationクラスからのBeanのインポートと非常に似ています。を使用@Qualifierする代わりに@Value、次のようにプロパティを使用します。
@Autowired
@Value("${some.interesting.property}")
private final String someInterestingProperty;
これはSpEL式でも使用できます。
 
SpringがそのようなクラスをBeanコンテナーとして扱うことができるようにするには、このタグをコンテキストに配置して、メインxmlでこれをマークする必要があります。 
<context:annotation-config/>
これで@Configuration、単純なBeanを作成するのとまったく同じようにクラスをインポートできます。
<bean class="some.package.MyApplicationContext"/>
完全にSpring XMLを回避する方法はいくつかありますが、この回答の範囲外です。これらのオプションの1つは、私のブログ記事で答えを見つけることができます。