`

spring extral features-----GenericApplicationContext

 
阅读更多
@Test
	public void test1(){
		GenericApplicationContext genericApplicationContext=new GenericApplicationContext();
		
		BeanDefinitionBuilder builder=BeanDefinitionBuilder.rootBeanDefinition(UserServiceImpl.class);

		BeanDefinitionBuilder daoBuilder=BeanDefinitionBuilder.rootBeanDefinition(UserDaoImpl.class);
		
		BeanDefinition definition=daoBuilder.getBeanDefinition();
		
		genericApplicationContext.registerBeanDefinition("userDao", definition);
		
		
		
		builder.addPropertyReference("userDao", "userDao");
		
		genericApplicationContext.registerBeanDefinition("userService", builder.getBeanDefinition());
		
		
		UserService userService=genericApplicationContext.getBean(UserService.class);
		
		userService.save("hotbain", "123456");
		
		genericApplicationContext.close();
		
		
	}

        动态实现bean的加载。

 

 

0
0
分享到:
评论

相关推荐

    开发工具 spring-web-4.3.6.RELEASE

    开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE开发工具 spring-web-4.3.6.RELEASE...

    开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist

    开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6.RELEASE-dist开发工具 框架JAR spring-framework-4.3.6....

    spring-context-support-1.0.10-API文档-中文版.zip

    赠送jar包:spring-context-support-1.0.10.jar; 赠送原API文档:spring-context-support-1.0.10-javadoc.jar; 赠送源代码:spring-context-support-1.0.10-sources.jar; 赠送Maven依赖信息文件:spring-context-...

    开发工具 spring-aop-4.3.6.RELEASE

    开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE...

    spring-ai-core-0.8.1

    spring-ai-core 0.8.1,解决大家使用2023.0.1.0 版本 Spring Cloud Alibaba 依赖,代码依赖下载报错问题, <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies <version>...

    spring-cglib-repack-3.2.0.jar和spring-objenesis-repack-2.1.jar

    在这个问题中,我们遇到了两个关键的jar包:`spring-cglib-repack-3.2.0.jar`和`spring-objenesis-repack-2.1.jar`。这两个jar包对于理解Spring框架的工作原理以及它们在实际应用中的作用至关重要。 首先,`spring-...

    spring-plugin-core-2.0.0.RELEASE-API文档-中文版.zip

    赠送jar包:spring-plugin-core-2.0.0.RELEASE.jar; 赠送原API文档:spring-plugin-core-2.0.0.RELEASE-javadoc.jar; 赠送源代码:spring-plugin-core-2.0.0.RELEASE-sources.jar; 赠送Maven依赖信息文件:spring...

    spring-data-commons-2.0.6.RELEASE-API文档-中文版.zip

    赠送jar包:spring-data-commons-2.0.6.RELEASE.jar; 赠送原API文档:spring-data-commons-2.0.6.RELEASE-javadoc.jar; 赠送源代码:spring-data-commons-2.0.6.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    spring-security-crypto-5.6.1-API文档-中文版.zip

    赠送jar包:spring-security-crypto-5.6.1.jar; 赠送原API文档:spring-security-crypto-5.6.1-javadoc.jar; 赠送源代码:spring-security-crypto-5.6.1-sources.jar; 赠送Maven依赖信息文件:spring-security-...

    spring-security-crypto-5.5.2-API文档-中文版.zip

    赠送jar包:spring-security-crypto-5.5.2.jar; 赠送原API文档:spring-security-crypto-5.5.2-javadoc.jar; 赠送源代码:spring-security-crypto-5.5.2-sources.jar; 赠送Maven依赖信息文件:spring-security-...

    开发工具 spring-core-4.3.6.RELEASE

    开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6.RELEASE开发工具 spring-core-4.3.6....

    seata-spring-boot-starter-1.3.0-API文档-中文版.zip

    赠送jar包:seata-spring-boot-starter-1.3.0.jar; 赠送原API文档:seata-spring-boot-starter-1.3.0-javadoc.jar; 赠送源代码:seata-spring-boot-starter-1.3.0-sources.jar; 赠送Maven依赖信息文件:seata-...

    spring-session-data-redis-2.0.4.RELEASE-API文档-中英对照版.zip

    赠送jar包:spring-session-data-redis-2.0.4.RELEASE.jar; 赠送原API文档:spring-session-data-redis-2.0.4.RELEASE-javadoc.jar; 赠送源代码:spring-session-data-redis-2.0.4.RELEASE-sources.jar; 赠送...

    spring-security-oauth2-2.3.5.RELEASE-API文档-中文版.zip

    赠送jar包:spring-security-oauth2-2.3.5.RELEASE.jar; 赠送原API文档:spring-security-oauth2-2.3.5.RELEASE-javadoc.jar; 赠送源代码:spring-security-oauth2-2.3.5.RELEASE-sources.jar; 赠送Maven依赖信息...

    spring-boot-actuator-autoconfigure-2.3.12.RELEASE-文档-中英对照版.zip

    赠送jar包:spring-boot-actuator-autoconfigure-2.3.12.RELEASE.jar; 赠送原API文档:spring-boot-actuator-autoconfigure-2.3.12.RELEASE-javadoc.jar; 赠送源代码:spring-boot-actuator-autoconfigure-2.3.12....

    spring-security-jwt-1.0.10.RELEASE-API文档-中文版.zip

    赠送jar包:spring-security-jwt-1.0.10.RELEASE.jar; 赠送原API文档:spring-security-jwt-1.0.10.RELEASE-javadoc.jar; 赠送源代码:spring-security-jwt-1.0.10.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    spring-context-support-5.0.5.RELEASE-API文档-中文版.zip

    赠送jar包:spring-context-support-5.0.5.RELEASE.jar; 赠送原API文档:spring-context-support-5.0.5.RELEASE-javadoc.jar; 赠送源代码:spring-context-support-5.0.5.RELEASE-sources.jar; 赠送Maven依赖信息...

    spring-cloud-context-3.1.1-API文档-中文版.zip

    赠送jar包:spring-cloud-context-3.1.1.jar; 赠送原API文档:spring-cloud-context-3.1.1-javadoc.jar; 赠送源代码:spring-cloud-context-3.1.1-sources.jar; 赠送Maven依赖信息文件:spring-cloud-context-...

    spring-security-core-5.3.9.RELEASE-API文档-中文版.zip

    赠送jar包:spring-security-core-5.3.9.RELEASE.jar; 赠送原API文档:spring-security-core-5.3.9.RELEASE-javadoc.jar; 赠送源代码:spring-security-core-5.3.9.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    spring-plugin-metadata-2.0.0.RELEASE-API文档-中文版.zip

    赠送jar包:spring-plugin-metadata-2.0.0.RELEASE.jar; 赠送原API文档:spring-plugin-metadata-2.0.0.RELEASE-javadoc.jar; 赠送源代码:spring-plugin-metadata-2.0.0.RELEASE-sources.jar; 赠送Maven依赖信息...

Global site tag (gtag.js) - Google Analytics