美文网首页
java 程序,springboot走shaodowscoks代

java 程序,springboot走shaodowscoks代

作者: 苏小小北 | 来源:发表于2018-10-08 11:36 被阅读0次

很多朋友想用java做科学研究工作,需要java程序能够走s5代理,这里提供一种简单的方式。
首先保证shadowsocks运行正常,在系统启动类前设置,

String proxyHost = "127.0.0.1";
String proxyPort = "1080";

System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);

// 对https也开启代理
System.setProperty("https.proxyHost", proxyHost);
System.setProperty("https.proxyPort", proxyPort);

附上springboot设置代理,

package cn.hinson;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * 启动类
 *
 */
@SpringBootApplication
public class App 
{
    public static void main( String[] args )
    {
        String proxyHost = "127.0.0.1";
        String proxyPort = "1080";
        System.setProperty("http.proxyHost", proxyHost);
        System.setProperty("http.proxyPort", proxyPort);
        // 对https也开启代理
        System.setProperty("https.proxyHost", proxyHost);
        System.setProperty("https.proxyPort", proxyPort);

        SpringApplication.run(App.class, args);
    }
}

这样程序就能通行无畅,访问需要的资源。

其他

本人也是在慢慢学习中,如有错误还请原谅、敬请指出,谢谢!

相关文章

网友评论

      本文标题:java 程序,springboot走shaodowscoks代

      本文链接:https://www.haomeiwen.com/subject/iebdaftx.html