All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties Maven / Gradle / Ivy

There is a newer version: 3.5.7
Show newest version
/*
 * Copyright (c) 2011-2020, baomidou ([email protected]).
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at *

* https://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.baomidou.mybatisplus.autoconfigure; import com.baomidou.mybatisplus.core.MybatisConfiguration; import com.baomidou.mybatisplus.core.config.GlobalConfig; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.GlobalConfigUtils; import lombok.Data; import lombok.experimental.Accessors; import org.apache.ibatis.scripting.LanguageDriver; import org.apache.ibatis.session.ExecutorType; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import java.io.IOException; import java.util.Optional; import java.util.Properties; import java.util.stream.Stream; /** * Configuration properties for MyBatis. * * @author Eddú Meléndez * @author Kazuki Shimizu */ @Data @Accessors(chain = true) @ConfigurationProperties(prefix = Constants.MYBATIS_PLUS) public class MybatisPlusProperties { private static final ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); /** * Location of MyBatis xml config file. */ private String configLocation; /** * Locations of MyBatis mapper files. * * @since 3.1.2 add default value */ private String[] mapperLocations = new String[]{"classpath*:/mapper/**/*.xml"}; /** * Packages to search type aliases. (Package delimiters are ",; \t\n") */ private String typeAliasesPackage; /** * The super class for filtering type alias. * If this not specifies, the MyBatis deal as type alias all classes that searched from typeAliasesPackage. */ private Class typeAliasesSuperType; /** * Packages to search for type handlers. (Package delimiters are ",; \t\n") */ private String typeHandlersPackage; /** * Indicates whether perform presence check of the MyBatis xml config file. */ private boolean checkConfigLocation = false; /** * Execution mode for {@link org.mybatis.spring.SqlSessionTemplate}. */ private ExecutorType executorType; /** * The default scripting language driver class. (Available when use together with mybatis-spring 2.0.2+) *

* 如果设置了这个,你会至少失去 mp 提供的有关填充到 entity 的 property 相关的功能 */ private Class defaultScriptingLanguageDriver; /** * Externalized properties for MyBatis configuration. */ private Properties configurationProperties; /** * A Configuration object for customize default settings. If {@link #configLocation} * is specified, this property is not used. * TODO 使用 MybatisConfiguration */ @NestedConfigurationProperty private MybatisConfiguration configuration; /** * TODO 枚举包扫描 */ private String typeEnumsPackage; /** * TODO 全局配置 */ @NestedConfigurationProperty private GlobalConfig globalConfig = GlobalConfigUtils.defaults(); public Resource[] resolveMapperLocations() { return Stream.of(Optional.ofNullable(this.mapperLocations).orElse(new String[0])) .flatMap(location -> Stream.of(getResources(location))) .toArray(Resource[]::new); } private Resource[] getResources(String location) { try { return resourceResolver.getResources(location); } catch (IOException e) { return new Resource[0]; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy