Skip to content

Commit 43108d5

Browse files
committed
Add @SpringBootApplication.scanBasePackages note
Update the javadoc to note that `scanBasePackages` only affects the `@ComponentScan` annotation and isn't a replacement for `@EntityScan` or `@Enable...Repositories`. Closes gh-18109
1 parent 8e6dbae commit 43108d5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/SpringBootApplication.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.context.annotation.Configuration;
3232
import org.springframework.context.annotation.FilterType;
3333
import org.springframework.core.annotation.AliasFor;
34+
import org.springframework.data.repository.Repository;
3435

3536
/**
3637
* Indicates a {@link Configuration configuration} class that declares one or more
@@ -72,6 +73,12 @@
7273
/**
7374
* Base packages to scan for annotated components. Use {@link #scanBasePackageClasses}
7475
* for a type-safe alternative to String-based package names.
76+
* <p>
77+
* <strong>Note:</strong> this setting is an alias for
78+
* {@link ComponentScan @ComponentScan} only. It has no effect on {@code @Entity}
79+
* scanning or Spring Data {@link Repository} scanning. For those you should add
80+
* {@link org.springframework.boot.autoconfigure.domain.EntityScan @EntityScan} and
81+
* {@code @Enable...Repositories} annotations.
7582
* @return base packages to scan
7683
* @since 1.3.0
7784
*/
@@ -84,6 +91,12 @@
8491
* <p>
8592
* Consider creating a special no-op marker class or interface in each package that
8693
* serves no purpose other than being referenced by this attribute.
94+
* <p>
95+
* <strong>Note:</strong> this setting is an alias for
96+
* {@link ComponentScan @ComponentScan} only. It has no effect on {@code @Entity}
97+
* scanning or Spring Data {@link Repository} scanning. For those you should add
98+
* {@link org.springframework.boot.autoconfigure.domain.EntityScan @EntityScan} and
99+
* {@code @Enable...Repositories} annotations.
87100
* @return base packages to scan
88101
* @since 1.3.0
89102
*/

0 commit comments

Comments
 (0)