- SpringBoot运行Test时报错:SpringBoot Unable to find a @SpringBootConfiguration
- mp代码生成模板--mybait-plus
- xm-select下拉树
- 级联模式
- data数据格式说明
- @MapKey的使用
- js的split和java的split函数一样,按照空格分割,返回分割得到的新数组
把@SpringBootTest()注解改成@SpringBootTest(classes = App.class)就可以了。就像这样:
SpringBoot运行Test时报错:SpringBoot Unable to find a @SpringBootConfiguration
mp代码生成模板–mybait-plus
@SpringBootTest(classes = Demo1Application.class)
class Demo1ApplicationTests {
@Test
void contextLoads()
{
//获取当前系统的目录
String ObjectPath = System.getProperty("user.dir");
//1.全局策略配置
GlobalConfig config = new GlobalConfig();
config.setActiveRecord(true)//是否支持AR模式
.setAuthor("大忽悠")//作者
.setOutputDir(ObjectPath+"/src/main/java")//生成路径
.setFileOverride(true)//文件覆盖
.setIdType(IdType.AUTO)//主键策略
.setServiceName("%sService")//设置生成service接口名字的首字母是否为I(默认会生成I开头的IStudentService)
.setbaseResultMap(true)//自动SQL映射文件,生成基本的ResultMap
.setbaseColumnList(true);//生成基本的SQL片段
//2.数据源配置
DataSourceConfig dataSourceConfig = new DataSourceConfig();
dataSourceConfig.setDbType(DbType.MYSQL)//设置数据库类型
.setDriverName("com.mysql.jdbc.Driver")//数据库驱动名
.setUrl("jdbc:mysql://localhost:3306/tx?useUnicode=true&characterEncoding=UTF-8")//数据库地址
.setUsername("root")//数据库名字
.setPassword("126433");//数据库密码
//3.策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setCapitalMode(true)//全局大写命名
.setNaming(NamingStrategy.underline_to_camel)//数据库表映射到实体的命名策略
.setColumnNaming(NamingStrategy.underline_to_camel)//列的命名也支持驼峰命名规则
.setInclude("s_coursetype")//设置要映射的表名,这里可以写多个
.setEntityLombokModel(true) //使用Lombok开启注解
.setRestControllerStyle(true)//开启驼峰命名格式
.setControllerMappingHyphenStyle(true);//controller层,开启下划线url : //localhost:8080/hello_id_2
//4.包名策略
PackageConfig packageConfig = new PackageConfig();
packageConfig
.setModuleName("com")//设置模块名
.setParent("xfx")//所放置的包(父包)
.setMapper("mapper")//Mapper包
.setService("service")//服务层包
.setController("controller")//控制层
.setEntity("pojo")//实体类
.setXml("mapper");//映射文件
//5.整合配置
AutoGenerator autoGenerator = new AutoGenerator();
autoGenerator.setGlobalConfig(config)
.setDataSource(dataSourceConfig)
.setStrategy(strategy)
.setPackageInfo(packageConfig);
//6.执行
autoGenerator.execute();
}
}
xm-select下拉树
xm-select
var demo2 = xmSelect.render({
el: '#course', //绑定的容器id
autoRow: true,//自动换行
filterable: true,//开启搜索框
//设置父图标的样式
iconfont: {parent:'layui-icon layui-icon-table'},
//下拉方向向下
direction: 'down',
//级联模式显示
cascader: {
//是否显示级联模式
show: true,
//间距
indent: 200,
//是否严格遵守父子模式
strict: true,
},
//工具栏
toolbar: {
show: true,
//只显示全选和清空
list: ['ALL', 'CLEAR']
},
//开启搜索,默认按照name搜索
filterable: true,
//高度自动
height: 'auto',
//数据
data: function ()
{
var res;
//使用axios发送ajax请求
$.ajax({
url: 'getCurriculumSystems',
type: "post",
dataType: "json",
async : false,//同步
success: function (data)
{
res=data
},
error: function ()
{
alert("出现异常")
}
})
return res
},
tips: '为当前用户开通课程权限',
empty: '当前没有课程可以选择',
searchTips: '搜索课程',
paging: true,
pageSize: 3,
filterable: true,
pageEmptyShow: false,
theme: {
color: '#0081ff',
}
})
data数据格式说明
return [
{name: '常规课程', value: -1, children: [
{name: '三岁课程', value:-2,children:[
{name:'搭积木',value:1},
{name:'拆积木',value:2},
]},
{name: '四岁课程', value:-3,children:[
{name:'搭积木',value:3},
{name:'拆积木',value:4},
]},
{name: '五岁课程', value:-4,children:[
{name:'搭积木',value:5},
{name:'拆积木',value:6},
]},
]},
{name: '假期课程', value: -5, children: [
{name: '寒假课程', value: -6, children: [
{name: '课程1', value: 7},
{name: '课程2', value: 8},
{name: '课程3', value: 9},
]},
{name: '暑假课程', value: -7, children: [
{name: '课程1', value: 10},
{name: '课程2', value: 11},
{name: '课程3', value:12},
]},
]},
]
如果value值为负数,说明其下面还有小分类,并且当我们展开常规课程时,常规课程对应的value=-1,那么下面如果出现重复的value值同样为-1,那么其同样会被展开
展开value为负数的下拉框时,与当前负数vlaue相同的下拉框也会被展开,因此负数value不要重复
当我们选择一个正数value的选项时,与当前正数value相同的选项同样会被选中,因此正数value也不要重复
总结:value值不要重复
@MapKey的使用
@MapKey("id")
Map> getInfoById(@Param("id") Long id, @Param("name") String name);
查询结果:
// 查询,返回结果:{1={area:上海,companyName=西西公司}}
// 如果是多条记录,返回结果如:{1={area:上海,companyName:西西公司},2={area:南京,compantyName:猴猴公司}}
Map> map = productDao.getInfoById(id, "公司名称");
@MapKey的使用
如果是下面这种情况,相把返回的每一条记录封装为一个map,然后用一个list集合来存放这些map,此时因为返回值用到了map,就必须加@MapKey指定key值,如果对于的key值,返回结果没找到,那么不会有任何效果
//获取所有课程体系
@MapKey("id")
public List
js的split和java的split函数一样,按照空格分割,返回分割得到的新数组
var powerArr = uPow.split(" ");
//这里是x-select设置多选框被选中,传入一个数组,设置多个被选中
demo2.setValue(powerArr);



