springboot中/*和/**在不同位置的区别

静态映射

前者后面只能直接跟文件名,后者后面可以跟多级目录,再跟文件名
/* 代表后面只能直接跟文件 : http://localhost:10011/aaa/002.html
/aaa/002.html ------》D:/aaa/002.html

/**
	 * 代表后面只能直接跟文件   http://localhost:10011/aaa/002.html      /aaa/002.html ------》/aaa/002.html
	 * @param registry
	 */
	 @Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.
				addResourceHandler("/swagger-ui/**","/aaa/*")
				.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/","file:D:/aaa/")
				.resourceChain(false);
	}

/** 代表后面能跟多个个目录,如 访问 http://localhost:10011/aaa/report/ddd/005.html /aaa/report/ddd/005.html----->D:/aaa/report/ddd/005.html

	/**
	 * /**   代表后面能跟多个个目录,如  访问  http://localhost:10011/aaa/report/ddd/005.html  report/ddd/005.html----->D:/aaa/report/ddd/005.html
	 * @param registry
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.
				addResourceHandler("/swagger-ui/**","/aaa/**")
				.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/","file:D:/aaa/")
				.resourceChain(false);
	}

指定路径

在mybatis中指定xml文件所在的位置时

    /**
     *1. 只可以找到mapper目录下以 .xml 为后缀的文件
     */
    static final String MAPPER_LOCATION = "classpath:mybatis/db/mapper/*.xml";

1.所有的xml文件只能直接放在mapper下,不能放在子文件夹中
在这里插入图片描述

2.只能放在mapper下的一级子目录(一级文件夹),如必须直接放在a文件下,如果直接放在mapper下或者放在a文件的子目录b文件夹,就会报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.leilankeji.mailboxes.db.dao.UserMapper.selectUsers

在这里插入图片描述

static final String MAPPER_LOCATION = "classpath:mybatis/db/mapper/*/*.xml";

3.不论放在mapper下的哪个位置都可以找到

static final String MAPPER_LOCATION = "classpath:mybatis/db/mapper/**/*.xml";

以上皆是鄙人愚见,如有错误,请多指教

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值