当前位置:网站首页>Pathmatchingresourcepatternresolver parsing configuration file resource file
Pathmatchingresourcepatternresolver parsing configuration file resource file
2022-07-26 04:05:00 【Grab】
Usage method :
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
Resource resource = resourcePatternResolver.getResource("youResourcePath");If it's not the root path , The path needs to be specified , for example :

From the classpath rules Get... In the directory demo.drl file
Resource resource = resourcePatternResolver .getResource("rules/demo.drl");Can be clearly specified classpath Prefix :
Resource resource = resourcePatternResolver .getResource("classpath:rules/demo.drl");Use wildcards to get files that meet a certain format
adopt classpath* Prefix specifies to get the specified file from all Classpaths
Resource[] resource = resourcePatternResolver .getResource("classpath*:rules/demo.drl");obtain rules Prefix under directory is demo The file of
Resource[] resource = resourcePatternResolver .getResource("classpath*:rules/demo*.drl");obtain com.a.rules、com.b.rules、com.c.rules In the catalog demo The file of
Resource[] resource = resourcePatternResolver .getResource("classpath*:com/*/rules/demo.drl");Two * Represents any multilayer directory
Resource[] resource = resourcePatternResolver .getResource("classpath*:com/**/rules/demo.drl"); Convert the read resource file into a string :
import org.apache.poi.util.IOUtils;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import java.io.IOException;
/**
* @author Xiang Zhenhua
* @date 2022/07/25 10:59
*/
public class ResourceUtils {
/**
* Read the configuration file and convert it into a string
*
* @param path route ,eg: classpath:META-INF/xxx/spring.factories
* @return
*/
public static String read(String path) {
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
Resource resource = resourcePatternResolver.getResource(path);
try {
byte[] bytes = IOUtils.toByteArray(resource.getInputStream());
return new String(bytes);
} catch (IOException e) {
return null;
}
}
}边栏推荐
- Matrix and Gauss elimination [matrix multiplication, Gauss elimination, solving linear equations, solving determinants] the most detailed in the whole network, with examples and sister chapters of 130
- 1311_硬件设计_ICT概念、应用以及优缺点学习小结
- [MCU simulation project] external interrupt 0 controls 8 LED flashes
- Web测试方法大全
- Can't the container run? The Internet doesn't have to carry the blame
- 基于移位寄存器的同步FIFO
- Educational Codeforces Round 132 (Rated for Div. 2) E. XOR Tree
- LeetCode. 6115 count the number of ideal arrays
- Communication protocol and message format between microservices
- Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%
猜你喜欢

Chapter 18: explore the wonders of the mean in the 2-bit a~b system, specify the 3x+1 conversion process of integers, specify an interval to verify the angular Valley conjecture, explore the number of

基于移位寄存器的同步FIFO
![[unity3d shader] character projection and reflection](/img/00/d0d994d88475ea590dc5cb60a6ad65.png)
[unity3d shader] character projection and reflection

构建关系抽取的动词源

Luoda Development -- the context of sidetone configuration
![Acwing game 61 [End]](/img/e3/191f7d888fc8cced608d41ef837a92.png)
Acwing game 61 [End]

Luoda development - audio stream processing - AAC / loopbacktest as an example

General test case writing specification

Opencv learning notes - edge detection and Canny operator, Sobel operator, lapiacian operator, ScHARR filter

深度学习之DAT
随机推荐
Can't the container run? The Internet doesn't have to carry the blame
基于移位寄存器的同步FIFO
Constructing verb sources for relation extraction
JS get some attributes of the object
构建关系抽取的动词源
Basic principles of iptables
Operator new, operator delete supplementary handouts
php 查找 session 存储文件位置的方法
《opencv学习笔记》-- 霍夫变换
Working ideas of stability and high availability guarantee
[in depth study of 4g/5g/6g topic-42]: urllc-13 - in depth interpretation of 3GPP urllc related protocols, specifications and technical principles -7-low delay technology-1-subcarrier spacing expansio
[oi knowledge] dichotomy, dichotomy concept, integer dichotomy, floating point dichotomy
涂鸦幻彩产品开发包如何使用
Course selection information management system based on SSM
KBPC1510-ASEMI大芯片15A整流桥KBPC1510
1311_ Hardware design_ Summary of ICT concept, application, advantages and disadvantages
微信小程序实现音乐播放器(5)
PHP <=> 太空船运算符(组合比较符)
What is the problem of the time series database that has been developed for 5 years?
`Oi problem solving ` ` leetcode '2040. The k-th minor product of two ordered arrays