最代码官方
2021-01-25 23:55:59
证
Spring自定义类似@Required注解实现在容器启动时对bean进行依赖校验
项目描述
上一个代码Spring通过@Required注解实现在容器启动时对bean进行依赖校验
是通过Spring内置的@Required注解实现的bean依赖的校验
这一个代码通过自定义注解实现类似机制
运行环境
jdk8+IntelliJ IDEA+maven
项目技术(必填)
spring+自定义Annotation
依赖包文件(可选)
链接:https://pan.baidu.com/s/1mAmWlS3H3MPmcK7NYxHrvg
提取码:silt
是否原创(转载必填原文地址)
转载https://memorynotfound.com/spring-custom-required-styled-annotation-example/
项目截图(必填)
运行截图(必填)
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'luke' defined in class path resource [app-config.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Property 'theForce' is required for bean 'luke' at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.memorynotfound.spring.core.required.Main.main(Main.java:9) Caused by: org.springframework.beans.factory.BeanInitializationException: Property 'theForce' is required for bean 'luke' at org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor.postProcessPropertyValues(RequiredAnnotationBeanPostProcessor.java:156) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ... 11 more
注意事项(可选)
运行Main即可
猜你喜欢
- java自定义注解实例
- spring注解annotation实例demo
- 分享通过spring注解实现的quartz job
- spring实现忽略禁用@Required注解的实例
- Spring两种常用的事务管理范例AspectJ和基于注解方式
- spring通过@Value注解注入到java List属性
- 基于spring转账Demo,基于注解AOP配置
- spring bean通过@Lazy注解实现延迟初始化实例
- Spring通过@Autowired注解实现Bean依赖注入的简单实例
- spring通过@Async注解实现异步执行Service方法并且通过Java Future对象得到执行结果
- 整合Spring MVC,mybatis,hibernate,freemarker框架实现的自定义注解Validator验证机制实现对敏感词过滤的代码分享
- Spring通过@Required注解实现在容器启动时对bean进行依赖校验
请下载代码后再发表评论
文件名:custom-spring-@required-annotation-example.zip,文件大小:6.409K
下载
- /
- /custom-spring-@required-annotation-example
- /custom-spring-@required-annotation-example/pom.xml
- /custom-spring-@required-annotation-example/src
- /custom-spring-@required-annotation-example/src/.DS_Store
- /custom-spring-@required-annotation-example/src/main
- /custom-spring-@required-annotation-example/src/main/java
- /custom-spring-@required-annotation-example/src/main/java/com
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required
/custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required/Main.java
/custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required/StarWars.java
/custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required/TheForce.java
/custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required/WeNeedThis.java
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core/required
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring/core
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound/spring
- /custom-spring-@required-annotation-example/src/main/java/com/memorynotfound
- /custom-spring-@required-annotation-example/src/main/java/com
- /custom-spring-@required-annotation-example/src/main/java
- /custom-spring-@required-annotation-example
相关代码
- spring 各种demo实例
- [工作必备]spring定时器简单的demo
- Java Spring定时器Demo, 可自动跳过节假日
- Spring两种常用的事务管理范例AspectJ和基于注解方式
- 证 Spring生命周期默认初始化和销毁方法通过xml配置实现
- 证 spring通过@Async注解实现异步执行Service方法并且通过Java Future对象得到执行结果
- spring实例入门教程
- spring入门实例demo
- spring整合rmi代码实例
- 原证精 spring如何注入List,Set,Map对象
- Spring Hibernate Spring Data MongoDB Akka Titles Bootstrap JQuery Maven 大全
- 证 spring实现忽略禁用@Required注解的实例
最近下载
最近浏览
fuyouou LV5
2023年7月6日
szf123 LV12
2023年5月30日
HusKies001
2021年6月29日
暂无贡献等级
wz66666 LV9
2021年6月8日
xiao菜 LV2
2021年6月2日
sanjooo LV5
2021年5月25日
xb1406112453 LV5
2021年4月15日
菜鸟蛋 LV2
2021年3月3日
fkhfsuhfuhflkk LV7
2021年2月20日
555551 LV1
2021年2月7日