This commit is contained in:
2023-06-06 17:52:07 +08:00
parent bd2c01fe40
commit 7f9c2a64c1
12 changed files with 383 additions and 243 deletions

View File

@ -24,14 +24,17 @@ public class IpConfig {
@PostConstruct
public void dbToCache() {
InputStream inputStream = null;
try {
ClassPathResource classPathResource = new ClassPathResource("ip2region.xdb");
InputStream inputStream = classPathResource.getInputStream();
inputStream = classPathResource.getInputStream();
IpUtil.setSearcher(Searcher.newWithBuffer(IoUtil.read(inputStream).toByteArray()));
log.info("加载IP离线库到内存成功");
} catch (Exception e) {
e.printStackTrace();
log.error("加载IP离线库到内存失败, 请联系管理员!");
} finally {
IoUtil.close(inputStream);
}
}