注释类型 Sql

      • scripts

        @AliasFor("value")
        String[] scripts
        The paths to the SQL scripts to execute.

        This attribute may not be used in conjunction with value(), but it may be used instead of value(). Similarly, this attribute may be used in conjunction with or instead of statements().

        Path Resource Semantics

        Each path will be interpreted as a Spring Resource. A plain path — for example, "schema.sql" — will be treated as a classpath resource that is relative to the package in which the test class is defined. A path starting with a slash will be treated as an absolute classpath resource, for example: "/org/example/schema.sql". A path which references a URL (e.g., a path prefixed with classpath:, file:, http:, etc.) will be loaded using the specified resource protocol.

        Default Script Detection

        If no SQL scripts or statements() are specified, an attempt will be made to detect a default script depending on where this annotation is declared. If a default cannot be detected, an IllegalStateException will be thrown.

        • class-level declaration: if the annotated test class is com.example.MyTest, the corresponding default script is "classpath:com/example/MyTest.sql".
        • method-level declaration: if the annotated test method is named testMethod() and is defined in the class com.example.MyTest, the corresponding default script is "classpath:com/example/MyTest.testMethod.sql".
        另请参阅:
        value(), statements()
        默认值:
        {}
      • statements

        String[] statements
        Inlined SQL statements to execute.

        This attribute may be used in conjunction with or instead of scripts().

        Ordering

        Statements declared via this attribute will be executed after statements loaded from resource scripts(). If you wish to have inlined statements executed before scripts, simply declare multiple instances of @Sql on the same class or method.

        从以下版本开始:
        4.2
        另请参阅:
        scripts()
        默认值:
        {}
      • config

        SqlConfig config
        Local configuration for the SQL scripts and statements declared within this @Sql annotation.

        See the class-level javadocs for SqlConfig for explanations of local vs. global configuration, inheritance, overrides, etc.

        Defaults to an empty @SqlConfig instance.

        默认值:
        @org.springframework.test.context.jdbc.SqlConfig