spring 引导中的类路径和类路径* 有什么区别?

what's the difference between classpath and classpath* in spring boot?

当我使用 spring 引导标志配置文件时,我发现:

有效:

spring.banner.location=类路径:banner.txt

不工作:

spring.banner.location=类路径*:banner.txt

那么 classpath: 和 classpath*: 有什么区别?

来自 Spring 文档

The wildcard classpath relies on the getResources() method of the underlying classloader. As most application servers nowadays supply their own classloader implementation, the behavior might differ especially when dealing with jar files. A simple test to check if classpath* works is to use the classloader to load a file from within a jar on the classpath: getClass().getClassLoader().getResources(""). Try this test with files that have the same name but are placed inside two different locations. In case an inappropriate result is returned, check the application server documentation for settings that might affect the classloader behavior.

所以classPath是用来从当前class加载器加载资源的(只是为了理解不会读取jar或其他项目依赖下的资源)

classpath* 将执行 jar 或其他 class 加载程序资源。

首先因为Spring在source.You中开机显示banner可以找到SpringApplication.class中的代码,printBanner方法用于显示banner.Like mallikarjun 说 classPath 用于从当前 class 加载器加载资源(只是为了理解不会读取 jar 或其他项目依赖项下的资源) classpath* 将执行 jar 或其他 class加载程序资源。 如果你使用 classpath*:banner.txt 会在 jar.

中找到