|
@@ -9,7 +9,6 @@ import org.springframework.core.io.ClassPathResource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.util.FileCopyUtils;
|
|
import org.springframework.util.FileCopyUtils;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
@@ -32,14 +31,9 @@ public class IPUtil {
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
DbConfig config = new DbConfig();
|
|
DbConfig config = new DbConfig();
|
|
- File file = new File("/ip2region.db"); // 本路获取资源文件
|
|
|
|
- if (!file.exists()) {
|
|
|
|
- Resource resource = new ClassPathResource("/ip2region.db"); // 远程获取资源文件
|
|
|
|
- InputStream inputStream = resource.getInputStream();
|
|
|
|
- searcher = new DbSearcher(config, FileCopyUtils.copyToByteArray(inputStream));
|
|
|
|
- } else {
|
|
|
|
- searcher = new DbSearcher(config, file.getPath());
|
|
|
|
- }
|
|
|
|
|
|
+ Resource resource = new ClassPathResource("ip2region.db"); // 远程获取资源文件
|
|
|
|
+ InputStream inputStream = resource.getInputStream();
|
|
|
|
+ searcher = new DbSearcher(config, FileCopyUtils.copyToByteArray(inputStream));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
System.out.println("获取DbSearcher错误");
|
|
System.out.println("获取DbSearcher错误");
|