Skip to content

Introduce Spring's AliasFor declaration in MapperScan #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/org/mybatis/spring/annotation/MapperScan.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AliasFor;

/**
* Use this annotation to register MyBatis mapper interfaces when using Java Config. It performs when same work as
Expand Down Expand Up @@ -67,7 +68,7 @@
*
* @author Michael Lanyon
* @author Eduardo Macarron
*
* @author Qimiao Chen
* @since 1.2.0
* @see MapperScannerRegistrar
* @see MapperFactoryBean
Expand All @@ -85,6 +86,7 @@
*
* @return base package names
*/
@AliasFor("basePackages")
String[] value() default {};

/**
Expand All @@ -93,6 +95,7 @@
*
* @return base package names for scanning mapper interface
*/
@AliasFor("value")
String[] basePackages() default {};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ void registerBeanDefinitions(AnnotationMetadata annoMeta, AnnotationAttributes a
}

List<String> basePackages = new ArrayList<>();
basePackages.addAll(
Arrays.stream(annoAttrs.getStringArray("value")).filter(StringUtils::hasText).collect(Collectors.toList()));

basePackages.addAll(Arrays.stream(annoAttrs.getStringArray("basePackages")).filter(StringUtils::hasText)
.collect(Collectors.toList()));
Expand Down