Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “什么是”呢;“价值”;在@Service注释中使用_Java_Spring_Annotations - Fatal编程技术网

Java “什么是”呢;“价值”;在@Service注释中使用

Java “什么是”呢;“价值”;在@Service注释中使用,java,spring,annotations,Java,Spring,Annotations,这两者有什么区别 @Service(value="test1") @Service("test1") 没有区别,但是如果注释将使用多个参数,并且您希望使用多个参数,则需要使用“value=“-语法”。有关参数的用法,请参阅-javadoc,或者只查看注释类: public @interface Service { /** * The value may indicate a suggestion for a logical component name, * t

这两者有什么区别

@Service(value="test1")

@Service("test1")

没有区别,但是如果注释将使用多个参数,并且您希望使用多个参数,则需要使用“value=“-语法”。有关参数的用法,请参阅-javadoc,或者只查看注释类:

public @interface Service {

    /**
     * The value may indicate a suggestion for a logical component name,
     * to be turned into a Spring bean in case of an autodetected component.
     * @return the suggested component name, if any
     */
    String value() default "";

}
它被称为“值”的原因以及您可以忽略它的原因可以从以下内容中找到:

允许省略该元素 a中的名称和等号(=) 单元素注释 元素名为value