Spring中Bean的4种依赖检查模式分别是什么

这期内容当中小编将会给大家带来有关Spring中Bean的4种依赖检查模式分别是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

下面我们来看看Spring中的Bean的4中依赖检查模式:simple,object,all,none.

1 simple:对基本类型,字符型和集合进行依赖检查。

Java代码

<?xml version="1.0" encoding="UTF-8"?>   "http://www.springframework.org/dtd/spring-beans.dtd">   <beans>   <bean id ="HelloWorld" class="com.jnotnull.HelloWorld"   autowire="autodectect" dependency-check="simple">   <bean>   <bean id="date" class="java.util.Date">   beans>

2 object:对依赖的对象进行检查

Java代码

<?xml version="1.0" encoding="UTF-8"?>   "http://www.springframework.org/dtd/spring-beans.dtd">   <beans>   <bean id ="HelloWorld" class="com.jnotnull.HelloWorld"   autowire="autodectect" dependency-check="object">   <bean>   <bean id="date" class="java.util.Date">   beans>

3 all:对全部属性进行检查

Java代码

<?xml version="1.0" encoding="UTF-8"?>   "http://www.springframework.org/dtd/spring-beans.dtd">   <beans>   <bean id ="HelloWorld" class="com.jnotnull.HelloWorld"   autowire="autodectect" dependency-check="all">   <bean>   <bean id="date" class="java.util.Date">   beans>

4 none:不进行依赖检查:

Java代码

<?xml version="1.0" encoding="UTF-8"?>   "http://www.springframework.org/dtd/spring-beans.dtd">   <beans>   <bean id ="HelloWorld" class="com.jnotnull.HelloWorld"   autowire="autodectect" dependency-check="none">   <bean>   <bean id="date" class="java.util.Date">   beans>

由此我们可以看出,依赖检查一般和自动装载进行配套使用。如果没有自动装载,也就没有依赖检查的必要了。

上述就是小编为大家分享的Spring中Bean的4种依赖检查模式分别是什么了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。