在 Java 11 中,Apache Shiro 在使用 ehcache 时可能会找不到默认的配置。以下是解决方法的代码示例:
确保在项目的依赖中包含 ehcache 相关的库。可以使用 Maven 或 Gradle 来管理依赖。
创建一个 ehcache 的配置文件,命名为 ehcache.xml。可以将其放在 src/main/resources 目录下。
在 ehcache.xml 文件中,添加 ehcache 的默认配置,例如:
[main]
...
cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager.configFile = classpath:ehcache.xml
...
这样,Apache Shiro 就能够在 Java 11 中找到 ehcache 的默认配置。