u
This commit is contained in:
1 parent
ba4506baf7
commit
5ef02d648a
6 files changed
+105
-5
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package com.crane.test;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Test2 {
|
||||
public static void main(String[] args) {
|
||||
String lon = "116.37304";
|
||||
String lat = "39.92594";
|
||||
String tk = "f1dbb4a15e82006fca57d3286bbc410a"; // 替换为你的真实 key
|
||||
|
||||
String postStrJson = String.format("{\"lon\":%s,\"lat\":%s,\"ver\":1}", lon, lat);
|
||||
String encodedPostStr = URLEncoder.encode(postStrJson, StandardCharsets.UTF_8);
|
||||
String url = String.format(
|
||||
"https://api.tianditu.gov.cn/geocoder?postStr=%s&type=geocode&tk=%s",
|
||||
encodedPostStr, tk
|
||||
);
|
||||
System.out.println(url);
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36")
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response.isSuccessful() && response.body() != null) {
|
||||
String result = response.body().string();
|
||||
System.out.println("响应内容:\n" + result);
|
||||
} else {
|
||||
System.out.println("请求失败,状态码:" + response.code());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,6 @@ export default defineConfig({
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
https: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, 'src')
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -30,3 +30,68 @@ go version
|
||||
go version go1.24.5 windows/amd64
|
||||
```
|
||||
|
||||
|
||||
|
||||
## GoModules 设置
|
||||
|
||||
### 全局设置
|
||||
|
||||
开启模块支持
|
||||
|
||||
```bash
|
||||
go env -w GO111MODULE=on
|
||||
```
|
||||
|
||||
设置代理
|
||||
|
||||
```bash
|
||||
# 官网全球代理
|
||||
go env -w GOPROXY=https://goproxy.io,direct
|
||||
# 七牛云代理
|
||||
go env -w GOPROXY=https://goproxy.cn,direct
|
||||
```
|
||||
|
||||
取消代理
|
||||
|
||||
```bash
|
||||
go env -w GOPROXY=direct
|
||||
```
|
||||
|
||||
关闭校验:当你下载某个模块时,Go 会从 `GOSUMDB` 查询并校验它的哈希值(与 `go.sum` 中对应),确保依赖内容的完整性和安全性。
|
||||
|
||||
```bash
|
||||
go env -w GOSUMDB=of
|
||||
```
|
||||
|
||||
检查是否生效 ,打开 `cmd` 输入
|
||||
|
||||
```bash
|
||||
go env GOPROXY
|
||||
```
|
||||
|
||||
输出 `https://goproxy.cn,direct` 的话即代表成功
|
||||
|
||||
### IDEA设置
|
||||
|
||||

|
||||
|
||||
设置成功后
|
||||
|
||||

|
||||
|
||||
## GoPath 设置
|
||||
|
||||
### 全局设置
|
||||
|
||||
```bash
|
||||
go env -w GOPATH="D:\devtool\golang\gopath"
|
||||
```
|
||||
|
||||
### IDEA设置
|
||||
|
||||

|
||||
|
||||
# GoLand创建项目
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user