gpt4 book ai didi

java - Spring Boot中的classpath和classpath*有什么区别?

转载 作者:行者123 更新时间:2023-12-02 01:32:29 28 4
gpt4 key购买 nike

当我使用 Spring Boot Banner 配置文件时,我发现:

它有效:

spring.banner.location=classpath:banner.txt

不工作:

spring.banner.location=classpath*: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用于从当前类加载器加载资源(只是为了理解不会读取jar或其他项目依赖项下的资源)

classpath* 将执行 jar 或其他类加载器资源。

关于java - Spring Boot中的classpath和classpath*有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55825124/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com