• spring 设置注解依赖 @Required


    @Required 是我们对必需要的东西进行注解,spring在运行时的时候会帮助我们检查依赖项是否存在。

    其实现分两部:

    1、在你的bean读经的model里面的相关属性加上@Required这个注解

    2、在你的xml文件中做一些配置:

      a、引入 

    xmlns:context="http://www.springframework.org/schema/context"

    http://www.springframework.org/schema/context

    http://www.springframework.org/schema/context/spring-context.xsd

       b、如下操作

    <beans>

    <!--在这里添加你的-->

    <context:annotation-config/>

    </beans>

    这样spring就会在运行的时候帮你检查required的项是否存在。

    如果没有在bean.xml中添加<context:annotation-config/>  那么即使在你的model中定义了@Required注解的话,这个注解不会生效。

  • 相关阅读:
    tcp笔记
    sublime使用技巧
    mysql笔记
    ubuntu安装mysql
    正则表达式笔记
    网络编程笔记
    swoole安装异步reids
    mysql的时间存储格式
    nginx环境的搭建
    php的闭包函数use的使用
  • 原文地址:https://www.cnblogs.com/codetime/p/6292482.html
Copyright © 2020-2023  润新知