@EggGump
2018-07-02T15:47:47.000000Z
字数 793
阅读 423
spring,maven相关
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="helloBean" class="com.yiibai.hello.impl.HelloWorldImpl">
</beans>
等效于以下JavaConfig的配置:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.yiibai.hello.HelloWorld;
import com.yiibai.hello.impl.HelloWorldImpl;
/* http://www.manongjc.com/article/1603.html */
@Configuration
public class AppConfig {
@Bean(name="helloBean")
public HelloWorld helloWorld() {
return new HelloWorldImpl();
}
}
context这样写
ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);