@@ -67,6 +67,8 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {
67
67
68
68
private boolean lazyInitialization ;
69
69
70
+ private boolean printWarnLogIfNotFoundMappers = true ;
71
+
70
72
private SqlSessionFactory sqlSessionFactory ;
71
73
72
74
private SqlSessionTemplate sqlSessionTemplate ;
@@ -86,6 +88,7 @@ public class ClassPathMapperScanner extends ClassPathBeanDefinitionScanner {
86
88
public ClassPathMapperScanner (BeanDefinitionRegistry registry ) {
87
89
super (registry , false );
88
90
setIncludeAnnotationConfig (!NativeDetector .inNativeImage ());
91
+ setPrintWarnLogIfNotFoundMappers (!NativeDetector .inNativeImage ());
89
92
}
90
93
91
94
public void setAddToConfig (boolean addToConfig ) {
@@ -111,6 +114,21 @@ public void setLazyInitialization(boolean lazyInitialization) {
111
114
this .lazyInitialization = lazyInitialization ;
112
115
}
113
116
117
+ /**
118
+ * Set whether print warning log if not found mappers that matches conditions.
119
+ * <p>
120
+ * Default is {@code true}. But {@code false} when running in native image.
121
+ * </p>
122
+ *
123
+ * @param printWarnLogIfNotFoundMappers
124
+ * Set the @{code true} to print
125
+ *
126
+ * @since 3.0.1
127
+ */
128
+ public void setPrintWarnLogIfNotFoundMappers (boolean printWarnLogIfNotFoundMappers ) {
129
+ this .printWarnLogIfNotFoundMappers = printWarnLogIfNotFoundMappers ;
130
+ }
131
+
114
132
public void setMarkerInterface (Class <?> markerInterface ) {
115
133
this .markerInterface = markerInterface ;
116
134
}
@@ -211,8 +229,10 @@ public Set<BeanDefinitionHolder> doScan(String... basePackages) {
211
229
Set <BeanDefinitionHolder > beanDefinitions = super .doScan (basePackages );
212
230
213
231
if (beanDefinitions .isEmpty ()) {
214
- LOGGER .warn (() -> "No MyBatis mapper was found in '" + Arrays .toString (basePackages )
215
- + "' package. Please check your configuration." );
232
+ if (printWarnLogIfNotFoundMappers ) {
233
+ LOGGER .warn (() -> "No MyBatis mapper was found in '" + Arrays .toString (basePackages )
234
+ + "' package. Please check your configuration." );
235
+ }
216
236
} else {
217
237
processBeanDefinitions (beanDefinitions );
218
238
}
0 commit comments