编译Spring Boot过程中需要访问“repo.maven.apache.org”,提示“UnKnownHostException”。
Host未建立映射关系,可以通过增加代理配置解决。
vim ./spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/testkit/GradleBuild.java
String[] newArguments = new String[arguments.length + 4]; System.arraycopy(arguments, 0, newArguments, 0, arguments.length); newArguments[arguments.length] = "-Dhttp.proxyHost=127.0.0.1"; newArguments[arguments.length + 1] = "-Dhttp.proxyPort=3128"; newArguments[arguments.length + 2] = "-Dhttps.proxyHost=127.0.0.1"; newArguments[arguments.length + 3] = "-Dhttps.proxyPort=3128";
其中,127.0.0.1和3128分别表示代理主机的IP地址和端口,操作时请需要根据实际代理环境配置。
BuildResult result = prepareRunner(newArguments).build();
String[] newArguments = new String[arguments.length + 4]; System.arraycopy(arguments, 0, newArguments, 0, arguments.length); newArguments[arguments.length] = "-Dhttp.proxyHost=127.0.0.1"; newArguments[arguments.length + 1] = "-Dhttp.proxyPort=3128"; newArguments[arguments.length + 2] = "-Dhttps.proxyHost=127.0.0.1"; newArguments[arguments.length + 3] = "-Dhttps.proxyPort=3128";
其中,127.0.0.1和3128分别表示代理主机的IP地址和端口,操作时请需要根据实际代理环境配置。
return prepareRunner(newArguments).buildAndFail();
请使用:set list检查格式。不能出现空格,请使用Tab作为代码缩进。